dstars5 Posted August 5, 2013 Share Posted August 5, 2013 Hey guys, I've run into a problem on my website. I need to send two emails when a form is processed. One is to me, one is to the person submitting the form. I've been using mail() but its performance is sketchy at best. Sometimes the email sends, sometimes is doesn't. Any suggestions on how to reliably send emails? I want to be sure I get the information I need, and they get a confirmation email. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted August 6, 2013 Share Posted August 6, 2013 (edited) the php mail() function is only an interface between php and your sending mail server. assuming that the sending mail server accepted the email from your php script (generally, a false value will be returned by the mail() function to your script when the email wasn't accepted and a php error is generated, are you testing for this in your script), the problem is something about the mail or a problem between the sending and the receiving mail server. are the emails going into the spam/junk folders or at they not being received (possibly not even being sent) at all, for both the email to you and to the visitor? a common problem is setting the From: mail header to be that of the visitor's email address. this usually causes the email to be put into the spam/junk folder because the email is being sent from your sending mail server, it is not being sent from the visitor's email server. in the case where the receiving mail server IS the mail server that matches the domain in the From: address and the email wasn't sent by any of the known mail servers that correspond to that domain, email is simply discarded. you actually need to set the Reply-to: header to be the visitor's email and the From: address must be an email at your sending mail server or you must have an SFP dns record at the domain in the From: address that says your sending mail server is authorized to send email for the domain in the From: address. another common problem is relaying restrictions on your sending mail server that require smtp authentication when both the from and to email addresses are external to the sending mail server. the php mail() function does not support smtp authentication. during testing, where you use email address at your sending mail server, the emails will work, but in real use, the from/to address may not satisfy the relaying settings and the email won't get sent. shorter-answer - everything about how your script use the mail() function, the email addresses being used, and your sending mail server must be correct. have you checked the logs on your sending mail server to see if a) it is accepting the emails from the php script, b) if there are any errors being reported when it tries to send them to the receiving mail server, and c) does your sending mail server require smtp authentication? Edited August 6, 2013 by mac_gyver Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.