just1ncase Posted March 30, 2010 Share Posted March 30, 2010 I'm having trouble with my email confirmation. They inconsistently not being sent to the people who submitted the form. I'm not sure whether I have my PHP code set-up correctly. The following is my PHP Code for my email confirmation: <?php $to=""; $subject=""; $message=""; $headers=""; /*Payment Email Method*/ if ($paymentMethod == "Paypal") { $emailPayment = "Credit Card/Paypal"; } else { $emailPayment = "Check<br/> <br/> Payment Instructions here. <br/>"; } $to = $email; $subject = "Registration Confirmation"; $message = '<html> <body> Content introduction here. <br/><br/> Registrant Information<br/> ----------------------------------------------------------<br/> Name: '.$name.'<br/> Title: '.$title.'<br/> Address: '.$address1.'<br/> Address 2: '.$address2.'<br/> '.$city.', '.$state.' '.$zip.'<br/> Home Phone: '.$phone.'<br/> Office Phone: '.$office.'<br/> Fax: '.$fax.'<br/> Email: '.$email.'<br/> <br/> <br/> Method of Payment<br/> ----------------------------------------------------------<br/> '.$emailPayment.'<br/> <br/> Registration Type<br/> ----------------------------------------------------------<br/> '.$emailReg.'<br/> <br/> Credits<br/> ----------------------------------------------------------<br/> '.$emailCredit.'<br/> <br/> Cost<br/> ----------------------------------------------------------<br/> Initial Conference Fee: $'.$emailCost1.'<br/> CE Credit Option Fee: $'.$emailCost2.'<br/> -----<br/> Grand Total: $'.$totalCost.'<br/> </body> </html>'; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: My Website <[email protected]>\r\n"; $headers .= "CC: [email protected]\r\n"; if (mail($to, $subject, $message, $headers)) { echo(" "); } else { echo("<p>Message delivery failed.</p>"); } ?> Is the if and else function for mail set-up correctly? Or should I just remove the else function because it's not needed to echo whether a person's message failed? Please let me know. Any help is appreciated. Thanks! I'm new to this forums and I just love the great functionality of PHP. I hope to help others with my avid PHP knowledge as well. Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/196954-email-confirmation-help/ Share on other sites More sharing options...
oni-kun Posted March 30, 2010 Share Posted March 30, 2010 The ELSE is fine. Your code seems to be correct (as long as mysite.com is replaced with your actual site in the headers) and should send atleast at the software level. The best chance of your e-mails not sending is either the SMTP server has error authenticating the headers, or is/was not reachable at the time it is sent. Try looking in logs. Quote Link to comment https://forums.phpfreaks.com/topic/196954-email-confirmation-help/#findComment-1033974 Share on other sites More sharing options...
Jax2 Posted March 30, 2010 Share Posted March 30, 2010 If it is a header problem, here's the header I use on my site. Never had an email missed, that I know of: [email protected] $headers = 'From: '.$from.'' . "\r\n" . 'Reply-To: '.$from.'' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); Quote Link to comment https://forums.phpfreaks.com/topic/196954-email-confirmation-help/#findComment-1033977 Share on other sites More sharing options...
just1ncase Posted March 30, 2010 Author Share Posted March 30, 2010 Thank you so much for the quick response! Yes, the "My Website <[email protected]>" will replaced the correct website name and email address. How would I be able to examine the logs? The odd thing is it was working just fine before, but stopped working all of a sudden now—Not sure why. It may be the error authenticating the headers Quote Link to comment https://forums.phpfreaks.com/topic/196954-email-confirmation-help/#findComment-1033978 Share on other sites More sharing options...
Jax2 Posted March 30, 2010 Share Posted March 30, 2010 I'm not sure about your host, but when I use my FTP program to log into my ftp account, there is a logs directory just before the website directory. All the error logs are stored in there. Quote Link to comment https://forums.phpfreaks.com/topic/196954-email-confirmation-help/#findComment-1033979 Share on other sites More sharing options...
oni-kun Posted March 30, 2010 Share Posted March 30, 2010 If your server has no SMTP logs then you're most likely using a shared host, if so then records sometimes need to be set or changed for proper use of PHP's mail function from the host itself. I'd recommend pinging your server (port 26 usually) over time and see if it's reachable, such as your MX records, but you really should ask your host to check if everything is alright on the record end. Quote Link to comment https://forums.phpfreaks.com/topic/196954-email-confirmation-help/#findComment-1033983 Share on other sites More sharing options...
just1ncase Posted March 31, 2010 Author Share Posted March 31, 2010 I couldn't find the SMTP logs, but I did find the website log (consisting of the web activity based on their IP address). From there, I was able to pin point the issue and resolve it from there. I think it wasn't a SMTP headers issue—instead, it may have been that email php function wasn't actually being accessed at all for it to trigger the email confirmations. So, I made that correction to the webpage. One question though: is it possible to send a copy of the email confirmation to me without my email address being on the CC line? Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/196954-email-confirmation-help/#findComment-1034534 Share on other sites More sharing options...
the182guy Posted March 31, 2010 Share Posted March 31, 2010 Sounds like it could be the recipients spam filter blocking the email. What are you using for the from email address, something like [email protected]? If so, it helps if that mailbox actually exists because some email providers will treat it as spam if the senders email address is nonexistent. Quote Link to comment https://forums.phpfreaks.com/topic/196954-email-confirmation-help/#findComment-1034540 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.