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. 🙂