geraldmpiper Posted April 12, 2007 Share Posted April 12, 2007 I'm doing some work on a client's server - how can I be sure that mail() will work? I'm using it in code, and I'm not getting any error messages, but I'm not getting any email through. $to = '[email protected]'; $from = '[email protected]'; $bcc = '[email protected]'; $subject = 'Test'; $message = 'This is a test.'; $headers = "From: Myname <$from>\r\n"; $headers .= "BCC: $bcc\r\n"; //leave the next 2 lines alone $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; if(mail($to, $subject, $message, $headers)) { echo "<br>Mail sent"; } else { echo "<br>Mail send failure - message not sent"; } Link to comment https://forums.phpfreaks.com/topic/46787-getting-mail-to-work/ Share on other sites More sharing options...
Glyde Posted April 12, 2007 Share Posted April 12, 2007 Check your junk mail folder. Link to comment https://forums.phpfreaks.com/topic/46787-getting-mail-to-work/#findComment-228042 Share on other sites More sharing options...
geraldmpiper Posted April 12, 2007 Author Share Posted April 12, 2007 Thanks. I wish it were that easy. Link to comment https://forums.phpfreaks.com/topic/46787-getting-mail-to-work/#findComment-228043 Share on other sites More sharing options...
per1os Posted April 12, 2007 Share Posted April 12, 2007 www.php.net/mail Look at the mail function and notice the [email protected] Try that, some servers require the -f to function properly, IE: if (mail($to, $subject, $message, $headers, '[email protected]')) { print "Sent Succesfully"; } Also a side note, I found on my server, if mail returns false it does not always mean the mail was not sent. I think this is was reported on php.net bug list but I am unsure. Just be wary that the mail may not always return what you expect it to. Link to comment https://forums.phpfreaks.com/topic/46787-getting-mail-to-work/#findComment-228053 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.