Beroc Posted December 23, 2011 Share Posted December 23, 2011 Howdy all. I come to you guys with a problem. I am using PHP to generate email to verify email address for people to log into the site that I am working on. Everything works fine, until I get the email. It says it comes from: myusername@hades.tchmachines.com This is nice and all but I would rather it say: webmaster@mysite.com Is this a setting on the server to use the PHP "from" field in the mail function or is this just a PHP question. basic code from php documentation: > $to = $email; $subject = "Thank you for registering at My Site"; $message = "<html><body>TEST</body></html>"; $headers = "MIME-Version: 1.0\r\n"; $headers = "Content-type: text/html; charset=iso-8859-1" . "\r\n"; $headers .= "From: webmaster@MySite.com" . "\r\n" . $headers .= "Reply-To: webmaster@MySite.com" . "\r\n" . $headers .= "X-Mailer: PHP/" . phpversion(); mail($to, $subject, $message, $headers); Any thoughts? Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted December 23, 2011 Share Posted December 23, 2011 You need to change the mail command to this >mail($to, $subject, $message, $headers, '-fwebmaster@example.com') Change webmaster@example.com to what ever email address you want it to be from. Quote Link to comment Share on other sites More sharing options...
OJB Posted January 4, 2012 Share Posted January 4, 2012 I came in here keen to post the -f flag that Bruce has done because this is something I've done several times at work to combat the issue of emails bouncing at receiving servers. The only thing I can add to this is that Bruce forgot the comma before the additional part. It should be: > mail($to, $subject, $message, $headers, '-fwebmaster@example.com') Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted January 5, 2012 Share Posted January 5, 2012 Thanks for the correction OJB, I'll update my post as well. 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.