Forum Moderators: coopster

Message Too Old, No Replies

php mail script

         

adamdidthis

12:30 pm on Sep 23, 2005 (gmt 0)

10+ Year Member



Hi I have this mail script


$key = mysql_insert_id();
$query = "SELECT * FROM userdeats WHERE idnum='$key'";

/* Execute the query */
$result = mysql_query($query);

/* get an array of the table results */
$values = mysql_fetch_array($result);
$req_email = $values['req_email'];
$new_user = $values['new_user'];
$new_pass = $values['new_pass'];
$new_email = $values['new_email'];

$mail_to= ".$req_email.";
$mail_subject= 'A requested user account has been created' ;
$mail_body= 'User account number ".$key." has been created. The detaisl are as followos: Username = ".$new_user." Password = "$.new_pass." E-mail address = "$.new_email."';
$headers= 'CC: itservices@example.tv';
$headers= 'From: itservices@example.tv';
mail($mail_to, $mail_subject, $mail_body, $headers);

and it returs the following error

mail() [function.mail]: SMTP server response: 501 5.5.4 Invalid Address

Can someone help me please, am a bit of a nubee

[edited by: jatar_k at 3:52 pm (utc) on Sep. 23, 2005]
[edit reason] examplified [/edit]

zeeshan_kh

1:56 pm on Sep 23, 2005 (gmt 0)

10+ Year Member



from the error i suppose the email you are sending the email to is not valid. If users are entering those email address then u must validate them before putting them in your DB.

You mite also wana add a "." before you second $header value to concatinate it with the first. Although i dont think that caused the error.

adamdidthis

2:49 pm on Sep 23, 2005 (gmt 0)

10+ Year Member



$req_email = $values['req_email'];

looks at a field in the database that does contain an email address

zeeshan_kh

3:14 pm on Sep 23, 2005 (gmt 0)

10+ Year Member



check to see if all the email addresses are valid. that includes CC and From

adamdidthis

3:18 pm on Sep 23, 2005 (gmt 0)

10+ Year Member



the CC and From addresses are correct, i think the problem is to do with the $mail_to= ".$req_email."; the problem is that I am not sure how to get the mail script to look at the fields i require and then stick the contents in the mail script. any help would be appreciated