I have Apache and mysql on my WinXP. I'm trying to use mail() to email the client if they fill some form and click the submit button, but I got error from mail().
In my php.ini, I set:
[mail function]
; For Win32 only.
SMTP = localhost
; For Win32 only.
sendmail_from = myEmaillAccount@somesite.com
Here is my code:
$to = "$client_email_address";
$subject = "................";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "To: $member <$client_email_address>\r\n";
$headers .= "From: my server side<myEmaillAccount@somesite.com>\r\n";
$msg = "blah blah ...";
if(mail($to, $subject, $msg, $headers))
echo "<br>Email has been sent to you.<br>";
else
echo "<br><p id=\"warning\">There is trouble in sending email.</p>";
It displays 'There is trouble in sending email.' and the error is:
Warning: mail(): SMTP server response: 550 5.7.1 Unable to relay for clientEmailAddress@someWebsite.com in c:\program files\apache group\apache\htdocs\signinhelp.php on line 178
Why would I have this error?
I found some code on the internet:
function sendMail($mailto, $mailfrom, $subject, $text, $format)
{
$maildrop="c:\\inetpub\\mailroot\\pickup\\";//change this to the
location of your mailroot
$filename=<work out some random filename here>;
$fp=fopen($maildrop.$filename, "w");
//different headers for different mail types
if($format=="plain")
fwrite($fp,"Content-Type: text/plain\r\nFrom:
$mailfrom\r\n");
else if($format=="html")
fwrite($fp,"Content-Type: text/html;
charset=iso-8859-1\r\nFrom: $mailfrom\r\n");
//write the email out to the file
fwrite($fp,"To: <$mailto>\r\n");
fwrite($fp,"Subject: $subject\r\n");
fwrite($fp,"\r\n");
fwrite($fp,"$text\r\n\r\n");
fclose($fp);
}
Can someone explain in this code where is 'the location of your mailroot' and what should I set on my PC? What is '<work out some random filename here>'?
Thanks