bravo14 Posted September 7, 2014 Share Posted September 7, 2014 Hi I am trying to use mail(), but when I try it i am not receiving the email. Code is as follows $username=$_POST['username']; $email=$_POST['email']; $password=$_POST['password']; //email user $from='registrations@ispeedwayscores.com'; $to=$email; $subject='Thank you for registering at iSpeedwayScores'; $message ='<html> <body bgcolor="#000000" style="color:#FF9900; font:Verdana, Arial, Helvetica, sans-serif"> <center> <h1>Welcome to iSpeedwayScores</h1> <br/> <p>Hi!</p> <br> <p>Thank you for joining iSpeedwayScores, this is your <b>FREE</b> online speedway scorecard site.</p> <p>Your login details are provided below:</p> Username: '.$username.'<br/> Password: '.$password.'<br/> <p>We hope you enjoy using the site, if you do, please tell others, if not please tell us</p> <h3>iSpeedwayScores</h3> </body> </html>'; //end of message $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; //options to send to cc+bcc $headers .= "Bcc: mark@bravo14.co.uk"; // now lets send the email. if(mail($to, $subject, $message, $headers)){ $message=" Message sent successfully"; $regsuccess = "Message sent successfully"; } else{ $message=" Message not sent"; $regfailure ="Message not sent"; } Although I get the Message sent successfully notification on screen. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted September 7, 2014 Share Posted September 7, 2014 have you ever successfully sent an email from the server where this is running? does your web host have any smtp authentication or other requirements to send email? there may be a mail server that accepted the email from the php mail() function and didn't return an error to php, but that mail server may not have any intention, or ability, of actually sending the email to the recipient or it may not even be the correct mail server to use at your web hosting. it's also possible that the dns records where the domain in your From: address is hosted at are either nonexistent or miss-configured such that the receiving mail server cannot determine if the sending mail server is authorized to send the email, in which case the receiving mail server may simply discard the email. is the From: address an actual working mail box, so that any bounce/error messages from the receiving mail server would have a place to go and can be viewed? and while the From: address should get used as the Return-path: address for bounce messages, you can specifically include a Return-path: in the header. edit: also, which email address are you not receiving at, the To: address that you are entering in the form (and have you confirmed that the form is posting a value to the code), or the Bcc: address that's in your code or both? Quote Link to comment Share on other sites More sharing options...
boompa Posted September 7, 2014 Share Posted September 7, 2014 You should really consider using a dedicated mailer class, like PHPmailer or SwiftMailer. 1 Quote Link to comment Share on other sites More sharing options...
Richard_Grant Posted September 8, 2014 Share Posted September 8, 2014 you are probably on your localhost you need to set up your sendmail.ini. If your not on your localhost then make sure your server is set up correctly. the problem is not with the code. 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.