Forum Moderators: coopster
I am fairly ignorant about how SMTP and PHP work together and have found most articles online assume at least a basic fundamental knowledge of how to setup php.ini to work with SMTP.
Warning: mail() [function.mail]: SMTP server response: 503 valid RCPT command must precede DATA in C:\wamp\www\base_ball\send_email.php on line 27
Email sent to:
I do not know what my error is here, the code looks okay. Maybe php.ini is wrong:
[mail function]
; For Win32 only.
SMTP = smtpauth.hosting.earthlink.net
smtp_port = 25; For Win32 only.
sendmail_from = you@yourdomain
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =
Here is my php code:
<?php
$from = #*$!@#*$!.#*$!;
$subject = $_POST['subject'];
$text = $_POST['broadcast_message'];$query = "SELECT last_name, first_name, mother, father,".
"mom_email, dad_email, personal_email,".
"preferred_email FROM player";
$result = mysql_query($query, $connection)
or die("Database query failed: " . mysql_error());
while($row = mysql_fetch_array($result)){
$last_name = $row['first_name'];
$first_name = $row['first_name'];
$mother = $row['$mother'];
$father = $row['father'];
$mom_email = $row['mom_email'];
$dad_email = $row['dad_email'];
$personal_email = $row['personal_email'];
$preferred_email = $row['preferred_email'];
$msg = "Dear $first_name $last_name,\n$text";
$to = $row['mom_email'];
mail($to, $subject, $msg, 'From:' . $from);
echo 'Email sent to: ' . $to . '<br />';
}
?>
<?php require("includes/footer.php"); ?>
SMTP server response: 503 valid RCPT command must precede DATA
Looks like the server rejected the RCPT command and issued the 503 when you tried to continue on like nothing was wrong. Try looking at the mail server logs if you can. If you can't do that, find some way to trace the transaction. (Wireshark?)
Some servers will refuse connection from dynamic IP addresses, this is my situation, you then need to configure through your isp smtp server to avoid the problem, on Linux it just means setting a smart_host in Sendmail I'm not sure on Windows
try here [no.php.net ]
Ashlin makes some suggestions
Hope that helps