Jump to content

Recommended Posts

Posted

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?

Posted

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.

  • 2 weeks later...
Posted

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

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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...