Jump to content
Sign in to follow this  
Beroc

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:

 

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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.

Guest
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.

Sign in to follow this  

×
×
  • Create New...