Reputation: 768
Been searching all over the net and tried many different solutions, also with phpmailer and other libraries.
My goal is to send a confirmation mail from my website, it works with hotmail and other services, but with gmail it ends up as junk.
Using the mail()
function, and page is hosted on one.com and sending mail do exists.
The code:
$mime_boundary = 'Multipart_Boundary_x'.md5(time()).'x';
$headers = "";
$headers .= 'MIME-Version: 1.0'."\r\n";
$headers .= "Content-Type: multipart/alternative; boundary=\"{$mime_boundary}\"\r\n";
$headers .= "Content-Transfer-Encoding: 7bit\r\n";
$body = "This is a multi-part message in mime format.\n\n";
# Add in plain text version
$body .= "--{$mime_boundary}\n";
$body .= "Content-Type: text/plain; charset=\"charset=us-ascii\"\n";
$body .= "Content-Transfer-Encoding: 7bit\n\n";
$body .= "To view the message, please use an HTML compatible email viewer!";
$body .= "\n\n";
# Add in HTML version
$body .= "--{$mime_boundary}\n";
$body .= "Content-Type: text/html; charset=\"UTF-8\"\n";
$body .= "Content-Transfer-Encoding: 7bit\n\n";
$body .= $this->_message;
$body .= "\n\n";
$body .= "--{$mime_boundary}--\n"; #
$headers .= 'From: Sender <[email protected]>'."\r\n";
$headers .= 'Reply-To: Sender <[email protected]>'."\r\n";
$headers .= 'Return-Path: Sender <[email protected]>'."\r\n";
$headers .= 'Message-Id: <' . md5(uniqid(microtime())) . '@example.com>'."\r\n";
$headers .= "X-Sender-IP: ". $_SERVER['SERVER_ADDR'] ."\r\n";
$headers .= 'X-Mailer: PHP/'. phpversion() ."\r\n";
mail($this->_to, '=?UTF-8?B?'. base64_encode("Subject - ". $this->_subject) .'?=', $body, $headers, "-f [email protected]");
Upvotes: 2
Views: 1133
Reputation: 14618
that simple, check if domain one.com is blacklisted:
http://www.mxtoolbox.com/SuperTool.aspx?action=blacklist%3a195.47.247.192
Upvotes: 2
Reputation: 67589
This great post from @JeffAtwood gives a huge amount of information regarding the caveats one will encounter when sending email and what should be done in order to reduce the probability of ending in the junk/spam folder.
Upvotes: 0
Reputation: 3823
As I remember need to be without space in last parameter.
"[email protected]"
instead of
"-f [email protected]"
Upvotes: 0
Reputation: 4363
Check that your IP (or your server's IP) isn't blacklisted: http://www.dnsbl.info/dnsbl-database-check.php
Upvotes: 1