I want to let users share information on my site by sending an email to a friend. Before I go to far I want to make sure I won't get blacklisted for doing something incorrectly.
If my domain is example.com can I set the mail FROM header to the email address supplied by the user?
For example, I want to share a page at example.com with my friend Bob. Bob's email address is bob@domain.com and my email address is me@anotherdomain.com. When example.com sends an email to Bob(bob@domain.com) it will set FROM to my email(me@anotherdomain.com).
Is this an issue since the email is being sent from example.com but the FROM header contains a domain other than itself?
The following would be sending from example.com
$to = 'bob@domain.com';
$subject = 'Some subject';
$msg = 'Some message';
$headers = 'From: me@anotherdomain.com <me@anotherdomain.com>' . "\n\r";
mail( $to, $subject, $msg, $headers );
Or do I need to do something like the following?
$headers = 'From: me@anotherdomain.com <share@example.com>' . "\n\r";
Any and all help will be greatly appreciated.
There are multiple email headers that give some indication of who "sent" an email and who to reply to. A fairly good, casual writeup of the concept can be found on the page discussing how FormMail handles things.
In general, the Sender is the actual originator of the email message. The From Address, in contrast, is simply a header line in the email that may or may not be taken to mean anything. The From Address can often be left out completely. Spammers can easily spoof the From Address. ISPs try to ensure that spammers cannot spoof the Sender.
It sounds like what you might want is: