smtp error with send to variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

smtp error with send to variable

Post by mhouldridge »

Hi,

I have the following code which loops through email addresses and is supposed to send the email to each user....... it is erroring. The variable email addresses are displaying fine in my echo output statement;

Code: Select all

$emailquery = "SELECT email_address FROM users";
$emailresult = mysql_query($emailquery) or die ("Query failed");
$numofrows = mysql_num_rows($emailresult);

for($i = 0; $i < $numofrows; $i++) {

$row = mysql_fetch_array($emailresult);
echo $row['email_address'];
mail ("$row", "*** update ***", 
"The news has been updated

Please log in a unread messages

This is an automated system message, please do no reply.");
}

I have never used variables for the to address. Here is the error;

Code: Select all

Warning: mail(): SMTP server response: 501 Syntax error. Syntax:{RCPT TO:<address> [SIZE=msgSize]} in C:\Audit\add_news2.php on line 392
Warning: mail(): SMTP server response: 501 Syntax error. Syntax:{RCPT TO:<address> [SIZE=msgSize]} in C:\Audit\add_news2.php on line 392
Warning: mail(): SMTP server response: 501 Syntax error. Syntax:{RCPT TO:<address> [SIZE=msgSize]} in C:\Audit\add_news2.php on line 392
Please help.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

need to include more in your associative array you do...enough $row is not.

try this you should:

Code: Select all

mail ($row['email_address'], "*** update ***", 
"The news has been updated 

Please log in a unread messages 

This is an automated system message, please do no reply.");
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

Post by mhouldridge »

I have echo'd $row in my loop, and each address is given.

My query specifies mysql_query("Select email_address,......

Therefore I am specifing the field....

?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

no, echoing "$row['email_address']; " you are.

use the same in your mail function you must. work by using simply "$row" it will not.
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

Post by mhouldridge »

You are right master yoda.

May the force be with you!
Post Reply