View Full Version : Mail problems

09-16-2005, 05:14 PM
I'm making a simple script to pull names from a data base and send them a letter. Here's the code:

$sql = "SELECT id, firstname, firstdate, emailaddy FROM automailer where firstdate = '$now'";
while($row = mysql_fetch_assoc($result)) {
$id = $row['id'];
$fname = $row['firstname'];
$email = $row['emailaddy'];

//first message (14 days)
$message = "<font face='verdana' size=2>Dear $fname,<br /><br />";
$message .= "<em>Where have you been?</em> <a href = \"http://www.cna-hgh.com\">www.cna-hgh.com</a> waiting for you as we have been now for over 7 years. We recognize that for many of you, price is an issue. Effective immediately, all Saizen (5 boxes) orders will receive a 10% discount and all Somatropin (5 boxes) orders will receive a 15% discount. That means that every individual that visits us at <a href = \"http://www.cna-hgh.com\">www.cna-hgh.com</a> or call us toll free at 1-888-254-7718 is eligible. These discounts do not apply to lab costs, physicals, and doctor consultations. <br /><br />";
$message .= "<em>What are you waiting for?</em> You want a fully licensed, FDA approved, 100% LEGAL doctor prescribed medical program! Get on board. Do not wait. Every caller will get complete care from every question to every answer. I personally guarantee it.<br /><br />";
$message .= "I hope to speak with you soon... <br /><br />";
$message .= "Gene Bolton President/CEO <br />";
$message .= "<a href=\"http://www.cna-hgh.com\">www.cna-hgh.com</a> <br />";
$message .= "email me at <a href=\"mailto:gene@cna-hgh.com\">gene@cna-hgh.com</a></font> <br />";
$message .= "<font face='verdana' size=2 color=red>toll free 1-888-254-7718</font>";

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: \"noreply@cna-hgh.com\" <noreply@cna-hgh.com>" . "\r\n";
mail($email, 'Response 1', $message, $headers);

The problem is, the first person to recieve an email doesn't get the whole message! It cuts off right after the message says President/ceo. The message is fine for all the other people. I've been racking my brain on this for a while and can't come up with a solution.

Can someone please help me? Or at least point me in the right direction?


09-16-2005, 09:06 PM
At cursory glance the code looks okay. If all else fails, you could obviously send the first email to yourself. ;)

09-20-2005, 11:36 AM
I figured it out, for anyone else who might have this problem. I didn't put any \n's in the script. I guess the first one was confused by that. After putting those in, it works fine.

09-25-2005, 09:00 PM

looking at your code.. here's a small piece of advice... since you are not making any changes you would be better off putting your headers outside the while loop... so that the processor cycles are not wasted interpreting same lines of code again and again... infact you can also keep your message outside the while loop... just call the mail function (like)...
mail($email, 'Response 1', "<font face='verdana' size='2'>Dear $fname,<br /><br />" . $message, $headers);
and remove this line from your code
$message = "<font face='verdana' size=2>Dear $fname,<br /><br />";

Infact it is much more recommended to create one include file with your own mailing function that has headers parameter with default value defined in it since generally we use the same headers for all mail functions in a single website.