Jump to content

Php Mail From Myusername@hades.tchmachines.com


Recommended Posts

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:




This is nice and all but I would rather it say:




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?

Link to comment
Share on other sites

  • 2 weeks later...

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')

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...