0

I want users on my website to use php mail() to send emails from my website domain. I would like users to get replies on their personal email address which will not be my domain email it might be gmail, hotmail or any other. When I do so, the email recipients get a phishing warning in gmail.

How can I set headers in php mail() so different sender and reply-to emails do not make gmail and other services tag the email as spam or phishing.

Passionate
  • 73
  • 2
  • 8
  • basically your lying about the source of the email, hence the warning, its hard to get around: http://stackoverflow.com/questions/8204050/sending-e-mail-via-php-on-behalf-of-someone-else –  Jan 22 '17 at 20:28

2 Answers2

0

Your recipients are getting a pishing warning because your emails are not passing SPF checks. That simply means that the from domain you are using is not authorizing your server to send mail on its behalf.

Try using PHPmailer https://github.com/PHPMailer/PHPMailer

You can use it to set a separate from address as well as a specific reply to address

$mail->AddReplyTo('replyto@email.com', 'Reply to name');
$mail->SetFrom('mailbox@email.com', 'Mailbox name');

That being said. The SetFrom address is an address that must pass SPF and preferably DKIM checks to be NOT marked as SPAM or PISHED. This address is recognized as the BOUNCE address where all the bounced emails will be returned to. Not having a valid address may possibly disrupt future deliveries.

The AddReplyTo address will be loaded when the reply button is clicked by the recipient. Keep in mind that even though the message may pass SPF there are many SPAM filters that will potentially mark the message as spam.

nrm
  • 153
  • 1
  • 6
  • as any SPF record would have to beset by the sending user, there is not a lot the OP can actually do here. simply using phpmailer will make no difference –  Jan 22 '17 at 21:04
  • Separating a `from address` from a `reply to` address will enable SPF checks. And therefore solve the requested problem. The solution is not to use PHPmailer. It is the distinct separation of the settings. – nrm Jan 22 '17 at 21:28
  • but the SPF record needs to be set on the senders domain –  Jan 22 '17 at 21:30
  • so where is a solution that will work for the OP in this "answer" ? –  Jan 22 '17 at 21:35
  • @nogad . Please read above solution `That being said. The SetFrom address is an address that must pass SPF and preferably DKIM checks to be NOT marked as SPAM or PISHED. ` If the **setFrom** is the sending servers address. A separate **replyTo** address can be set which does not have to pass a SPF check. – nrm Jan 22 '17 at 21:35
  • Here I am using 3 different info when using phpmailer, `$mail->Sender = $resultGroup->email; //the sender domain email. $mail->SetFrom($senderEmail, $senderName); //any email of sender like gmail, hotmail $mail->AddReplyTo($replyEmail, $replyName);//any email` Will this header be marked as phishing too? – Passionate Jan 23 '17 at 11:35
  • Yes it will. Setting `setFrom` to an email address other than one that passes SPF will cause it to be marked as **PISHED**. I am assuming gmail or hotmail do not list your server as an allowed server. I would recommend you use as service like http://mail-tester.com to trouble shoot. – nrm Jan 24 '17 at 00:00
0

The easiest way to get this working is to create an email address on your website (me@mysite.com) then get the website to automatically forward all mail to your gmail account. Then, use the website email address in the 'From' and 'Reply-To' address of your mail() routine.

Tim Makins
  • 394
  • 4
  • 12