Question

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.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top