Reputation: 1
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 = "[email protected]";
$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, [email protected] instead of just MyWebsite
Upvotes: 0
Views: 84
Reputation:
You can't specify MyWebsite
as sender because it's not a valid email address. You could try the following code:
$headers = "From: MyWebsite <[email protected]> \r\n";
Upvotes: 0
Reputation: 53533
Try setting the from address to the string (including the quotes):
"MyWebsite" <[email protected]>
Upvotes: 0
Reputation: 6748
Try this:
$headers = "From: MyWebsite <[email protected]> \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.)
Upvotes: 0
Reputation: 3267
I think
$headers = "From: MyWebsite <[email protected]> \r\n";
would do
If not, try reading http://www.sitepoint.com/advanced-email-php/
Upvotes: 1
Reputation: 11175
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.
Upvotes: 0