PhpDig.net

Go Back   PhpDig.net > General Forums > Coding & Tutorials

Reply
 
Thread Tools
Old 09-16-2005, 05:14 PM   #1
Brock
Green Mole
 
Join Date: Sep 2005
Posts: 4
Mail problems

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'";
$result=mysql_query($sql);
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?

Brock
Brock is offline   Reply With Quote
Old 09-16-2005, 09:06 PM   #2
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
At cursory glance the code looks okay. If all else fails, you could obviously send the first email to yourself.
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Old 09-20-2005, 11:36 AM   #3
Brock
Green Mole
 
Join Date: Sep 2005
Posts: 4
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.
Brock is offline   Reply With Quote
Old 09-25-2005, 09:00 PM   #4
ruchit
Green Mole
 
Join Date: Sep 2005
Posts: 3
just an advice

brock

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.
ruchit is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Exécution intempestive de mail() ? - Inopportune mail() carrying out ? philbihr Troubleshooting 1 11-16-2004 02:21 AM
Mail Attachments griffinmt Coding & Tutorials 2 06-13-2004 04:21 PM
Mail from webmaster Yannick Troubleshooting 11 01-14-2004 01:38 PM


All times are GMT -8. The time now is 01:58 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.