1

I am new to php and I am trying to send a confirmation email:

public static function sendAuthenticationEmail($username, $email, $uuid) {
    $subject = "Register email address";
    $headers = 'MIME-Version: 1.0' . PHP_EOL . 
               'Content-type: text/html; charset=iso-8859-1' . PHP_EOL . 
               'To: ' . $username . ' <' . $email . '>' . PHP_EOL . 
               'From: whereisthemonkey <noreply@whereisthemonkey.me>' . PHP_EOL .
               'X-Mailer: PHP/' . phpversion();
    $link = 'http://localhost/Whereisthemonkey/FileSystem/EmailSystem.php?email=' .
            $email . '&uuid=' . substr($uuid, 0, 14);
    $message = '
        <html>
            <head>
                <title>Email authentication</title>
            </head>
            <body style="color: #000080">
                <p style="font-weight: bold; color: #990000">Do not reply to the email!</p>
                <p>Hey ' . $username . ', this email has recently been used as authentication on <b>Whereisthemonkey</b>!<br><br>
                If that was you, please click 
                <a href="' . $link . '">here</a><br><br>
                <p>If that was not you, please just ignore this email!</p>
                <p>Have a nice day, the whereisthemonkey team!
            </body>';
    return mail($email, $subject, $message, $headers);
}

The mail is sent, but never arrives on the server (in this case gmail).

What am I doing wrong?

Thank you very much, Lucas!

Lucas Romier
  • 1,291
  • 1
  • 13
  • 22

1 Answers1

2

Maybe Gmail blacklist your server IP address OR the email is going to your spam folder.

Try to put the same code in a different server or use SMTP connection.

Asaf
  • 557
  • 1
  • 7
  • 15