开发者

php email changing the "from" address

开发者 https://www.devze.com 2023-03-23 11:43 出处:网络
I am trying to send automated emails with a clean \"From\" address.When it sends the email its using the name I want with @my-website.com attached right after, how do I get rid of it?

I am trying to send automated emails with a clean "From" address. When it sends the email its using the name I want with @my-website.com attached right after, how do I get rid of it?

Example

  $address = "user@example.com";
    $subject = "Confirmation";
    $msg = "Registered";
    $headers = "From: MyWebsite \r\n";

    mail($address, $subject, $msg, $headers);

The result I get in my inbox when I test it is, MyWebsite@my-开发者_开发问答website.com instead of just MyWebsite


I think

$headers = "From: MyWebsite <MyWebsite@my-website.com> \r\n";

would do

If not, try reading http://www.sitepoint.com/advanced-email-php/


It's working correctly. You need the complete domain with mail() it's required for the mail() function to parse and legally under the CAN-SPAM act.


Try this:

$headers = "From: MyWebsite <MyWebsite@my-website.com> \r\n";

This will show the name "MyWebsite" in most email clients, and also includes your email address. (Valid email should have a real From: email address.)


Try setting the from address to the string (including the quotes):

"MyWebsite" <whatever@my-website.com>


You can't specify MyWebsite as sender because it's not a valid email address. You could try the following code:

$headers = "From: MyWebsite <whatever@my-website.com> \r\n";
0

精彩评论

暂无评论...
验证码 换一张
取 消