Solved: php: sending an e-mail from a web browser application
I'm trying to get this test script working:
$to = "a valid email address";
$subj = "Test mail";
$msg = "Hello! This is a simple email message.";
$hdr = "From: test script";
$rslt = mail($to, $subj, $msg, $hdr);
echo "rslt = $rslt<br />";
If, for "a valid email address", I use my yahoo.com address, I receive the email.
If, on the other hand, I use my xs4all.nl address (my regular email), no mail arrives, neither in my inbox nor in the spambox.
According to the xs4all tech desk website, these are the required settings:
Instellingen e-mail via POP (instellingen = settings)
Inkomende mailserver pop.xs4all.nl (poort 110) (inkomende = incoming)
Uitgaande mailserver smtp.xs4all.nl (poort 25) (uitgaande = outgoing)
Any idea why the application won't send the email to my xs4all address?
First off Andy, do you get "rslt = true" on both addresses? If you do I would suggest that it may be a server issue.
Some Windows servers can get cross if "From:" is not a valid address, as they use it for ReplyTo (which has to be valid if present). I'd give that a go, and I'd also try setting the SMTP server back to localhost and see if that has any effect.
Thanks for your reply, Danny.
The rslt is "true" whether the code is as shown above or as revised below.
I changed the command adding the -f parameter which I found under "additional parameters" on the php.net website in the mail function doc.
$f = "-f $to";
$rslt = mail($to, $subj, $msg, $hdr, $f);
That works both with the php.ini SMTP parameter set to either localhost or as shown above. So I have left it as localhost.
THIS THREAD HAS EXPIRED.
Are you having the same problem?
We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.