Hi
I was wondering if anyone could let me know if its possible to send HTML emails in PHP thats aren't recognised as Junk by Windows Live Hotmail/Yahoo.
Thanks in advance.
Hi
I was wondering if anyone could let me know if its possible to send HTML emails in PHP thats aren't recognised as Junk by Windows Live Hotmail/Yahoo.
Thanks in advance.
Hi totw,
First of all, if you want a chance of your mail making it to your intended person, have a real person in mind. IE don't SPAM someone, have a legitimate, subscribed person who wants your email and you will have a chance of it arriving. With that said.
You need to do several things.
1) Have a well planned email with Subject, Message, Mail to and Mail fom to start.
2) Be sending from a non-blacklisted server (or ISP) Your site my be spotless, but another site on a co-located (shared ISP host) that is blacklisted and your email will be history.
3) Have a properly configured mailserver setup or use your ISP's mailserver.
Here is some simple code (not tested), but this will work best when sent to a single 'real' person with their 'real' name in the subject line.
$fp = fsockopen(localhost, 25, $errno, $errstr, 30);
$DisplayDate = date('m/d/y');
$email_to = $email_to;
$FirstName = $FirstName;
$LastName = $LastName;
$Title = $Title;
echo 'Sending email to -->'.$FirstName.' '.$LastName.' '.'at '.$email_to.'<br>';
//Send email to them
$message = '<html><head><title>Subscribed email alert.</title></head><body><font size="2" face="Arial, Helvetica, sans-serif">Body copy goes here.<br><br>You are subscribed to our email service.<br><br><a href="http://www.somewhere.com">www.somewhere.com</a>.<br />If you no longer wish to receive these emails, simply email us at <a href="mailto:removeme@somewhere.com">removeme@somewhere.com</a><br /></font></body></html>';
$header = 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$header .= "From: somebody@somewhere.com\r\n";
$subject = $DisplayDate.' '.$Title;
mail($email_to, $subject ,$message ,$header) ;
fclose($fp); // close fp port
That should get you in the ballpark. Again, don't use this for SPAM.
regards,
Don
(EDIT)
A Couple of notes here.
1) I found that in the $message that you cannot have any extra spaces or it will not deliver to most mail servers. Why, dunno, just won't.
2) in the header you will notice I use single and double quotes mixed, again, seems to work best with the "\r\n" .
Anyone have more insight on these 'please' share it.
dmacman1962 wrote:2) in the header you will notice I use single and double quotes mixed, again, seems to work best with the "\r\n" .
Eh... that doesn't change anything - using double quotes only would achieve the same result.
I would also consider adding an SPF record for your domain at your DNS servers and make sure that the server PHP is running on is allowed to send mail for your domain.
You could also search around the board for more headers to include to make your e-mail look more legitimate. Also verify that the domain of the "From" address you're specifying actually resides on the domain that PHP is sending mail from.
Finally, if you can get a hold of one of the messages that Hotmail/Yahoo has sent to the Junk folder, perhaps you might find some insight as to why the message was blocked if you examine the e-mail headers? Some spam software adds reasons into the header showing which patterns were tripped that led the e-mail to be marked as spam.
I looked at the email headers and I think the problem is that its coming from apache@localhost: Received: (from apache@localhost)
Does anyone know how to change this to the websites actual domain?
I don't think the Received: header matters at all - that just shows the path that the message took through the various gateways.