tawevolution Posted May 5, 2007 Share Posted May 5, 2007 Hi, Im trying to use the mail() function. Here is my code: <?php $to = "email@address.co.uk"; $subject = "subject here!"; $body = "this is the body section of the email message"; if (mail($to, $subject, $body)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> Every time i run the script, it says "Message successfully sent!".... so i then go over to my email inbox (i set the $to to my own email as a test) and the email never comes through. I have checked my email spam box, and i have tried several different email accounts (using diff email providers) .... none of which get through. Someone told me to make sure the 'safe_mode' was off, and 'register_globals' was on - of which they both are ...... any ideas????? Thanks Evo Quote Link to comment Share on other sites More sharing options...
paul2463 Posted May 5, 2007 Share Posted May 5, 2007 Hello I have just tried to run your code on my system which sows all errors for testing purposes and got the following error Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in C:\Program Files\xampp\htdocs\phptest\mail.php on line 7 Message delivery failed... try this but modify for taste <?php $to = "email@address.co.uk"; $subject = "subject here!"; $body = "this is the body section of the email message"; $headers = 'From: Birthday Reminder <birthday@example.com>' . "\r\n"; if (mail($to, $subject, $body, $headers)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted May 5, 2007 Share Posted May 5, 2007 You intial code is ok. Are you testing this on your own machine or on a live server? If its your own machine then check that you have set the SMTP setting in your php.ini file (set it to what ever your service providers smtp is) Quote Link to comment Share on other sites More sharing options...
tawevolution Posted May 6, 2007 Author Share Posted May 6, 2007 Are you testing this on your own machine or on a live server? If its your own machine then check that you have set the SMTP setting in your php.ini file (set it to what ever your service providers smtp is) Its on a live server .... so what should i do to make it work? Quote Link to comment Share on other sites More sharing options...
tawevolution Posted May 6, 2007 Author Share Posted May 6, 2007 sorry for double post ..... I have marked this post as solved because I found out why it wasnt working. I was sending an email to my hostings email accounts - and it doesnt like that - so i just created temp @gmail.com accounts and set up forwarders evo out thanks for your hepl guys 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.