Skip to content Skip to sidebar Skip to footer

Failed To Send Html Mails Using Php Mail()

Strange things happening to me. I'm trying to send a HTML mail, using the php mail() function, but no luck here. Even when I copy/paste a piece of code literally, it doesn't work.

Solution 1:

We can't see where the variable $email was set, but I'm guessing that there might be an extra line break at the end of your $email variable. This would have the effect of putting in two linebreaks after the From: header and before the Reply-to: , which signals the start of the body of the message and the completion of the headers.

Try:

$email = trim($email);

before constructing the message. Since there appears to be an extra line break after the Reply-to header as well, my case is even stronger for an extra break in $email.

UPDATE

Also try changing the linebreaks to PHP's native format on the system where the code will run. This is done by replacing \r\n with PHP_EOL

$headers = "From: " . $email . PHP_EOL;
    $headers .= "Reply-To: ". $email . PHP_EOL;
    $headers .= "MIME-Version: 1.0" . PHP_EOL;
    $headers .= "Content-Type: text/html; charset=ISO-8859-1" . PHP_EOL;

Solution 2:

Here is a useful link to sending html emails in php

http://blog.twigahost.com/how-to-send-html-email-with-php/

Solution 3:

I recommend you to use a mailer class. They give you the possibility to use smtp auth, so every mail will be passed through. A few examples:

Post a Comment for "Failed To Send Html Mails Using Php Mail()"