I've been struggling with this email function for a while. So basically, I'm working on a local website for a personal project, and I've run into problems with my email verification process. I have the framework in place to support it, but not the means to send an email; that's what this is about.

I have two functions, '*register*' and '*registerEmail*', which I want to work in tandem. '*register*' is self explanatory; it handles everything with the registration process, while '*registerEmail*' sends the email that users get in order to activate their account with a provided link.

My problem arises when I try to run '*registerEmail*' inside of '*register*', it simply doesn't... register. The '*register*' function works as intended and adds the user to the tables, but doesn't 'send' any email. However, it's not a problem with the '*registerEmail*' function because if I call it independently, it works perfectly fine... I already tried to combine the two functions out of desperation (didn't send an email), and it seems I'm at my wits end.

Here's the two mentioned functions:

Register function:
==================

```
public function register($array){

            ....
            all of the password and query stuff happens here
            ....

                $stmt->bind_param('ssssssiss', $userName, $password, $salt, $email, $firstName, $lastName, $today, $activationCode, $active);

                $stmt->execute();

            }else{

                printf("Prepared statement error: %s\n", $this->connection->error);

            }

            if($stmt->affected_rows == 1){

                return 1;

            }

            $stmt->close();

            #This part is the fault that I cannot pinpoint, it doesn't actually do anything.
            $this->registerEmail($userName, $email, $firstName, $lastName, $activationCode);

        }

    }

```

Register EMail function:
========================

```
public function registerEmail($userName, $email, $firstName, $lastName, $activateCode){

    $to = $email;

    $subject = 'Confirmation from Tangleball to ' . $userName;
    $header =   'From: webmaster@example.com' . "\r\n" .
                'Reply-To: webmaster@example.com' . "\r\n" .
                'X-Mailer: PHP/' . phpversion();

    $message = '<html><head><title>Email verification</title></head><body>';
    $message .= 'Hi ' . $firstName . $lastName . '! Your account, username "' . $userName . '", at place needs to be confirmed before you can log in, just <a href="http://127.0.0.1/place/index.php?activate=' . $activateCode . '">click here</a> to activate your place account. </body></html>';

    #$message = wordwrap($message, 70, "\r\n");

    $sentmail = mail($to, $subject, $message, $header);

}

```

I'm using [a local mail server](http://www.toolheap.com/test-mail-server-tool/) to "catch" the email being sent, so if I call my registerEmail function, it actually 'sends' the email to the 'user'.

I'm at a loss, can anyone poke some holes in my things?