Reputation: 10564
I'm trying to send out emails with PHP using this code
$headers = "From: " . "[email protected]" . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=utf-8\r\n";
mail($to, $subject, $content, $headers);
where $to
is a valid email address and $content
is the content of an html template.
@gmail and @hotmail addresses both receive the emails correctly. @virgilio.it addresses doesn't receive them: what can be causing this? Some domains are accepting and displaying emails from my server: other don't. Why is this?
Upvotes: 0
Views: 617
Reputation: 443
If messages are not received, try using a LF (\n) only. Some Unix mail transfer agents (most notably » qmail) replace LF by CRLF automatically (which leads to doubling CR if CRLF is used). This should be a last resort, as it does not comply with » RFC 2822.
http://www.faqs.org/rfcs/rfc2822.html
I do recommend to use a full featured email transfer class for PHP
Check the phpmailer calss http://code.google.com/a/apache-extras.org/p/phpmailer/source/browse/trunk/class.smtp.php?r=7
Upvotes: 1
Reputation: 20899
The php mail()
function uses the local smtp server. Usually if a mail is not accepted, this is because of a bad configuration of your local smtp server. (Open Relay-Access, wrong Reverse-IP-Lookup, dynamic ip, and so on...)
Use the PHPMailer
(https://github.com/PHPMailer/PHPMailer) class and use a (valid) smtp server.
Upvotes: 1
Reputation: 531
Some servers block the mail due to the 'from' header email address being set to a host that does not resolve (myself.com).
Try using a real email address in the 'from' header.
Upvotes: 0