Jump to content

Mail Function "From" Problem


usedearplugs

Recommended Posts

When sending email using the mail function in PHP, I can't get the from field to show what I want it to. In the header, I set the from email to be webmaster@mysiteExample.com, but it comes out with somemailboxcode123@mysiteExample.com. How can I fix this?

 

Here's a slightly modified version of my code

function email($from, $name, $subject, $body){
    $emailFrom="webmaster@mysite.com";
    $headers = 'From: Web Form <' . $emailFrom . '>' . "\r\n" .
    'Reply-To: ' . $aDifferentEmailAddress . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
    $send = mail($emailTo, $subject, $body, $headers);
}
Link to comment
Share on other sites

Thank you so much for your reply! I did actually try it that way first (no name, just email address).

 

I could even see how some email clients may show the from differently, but the funny thing is I check the headers in the email and it never even shows the "webmaster" email address anywhere in the email headers.

 

I have also echoed the $headers variable to ensure that it does actually show the proper "From: name <webmaster@mysite.com>"...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.