1

I configured my Windows Server 2016 with IIS to pickup mail() from php and send them to stmp.sendgrid.net.

To test my configuration, I can telnet my localhost and send email from there with no problem.

However, if I send the email via a mail() php function, SendGrid receive the request, but blocks it with this error:

REASON550 5.7.1 [167.89.55.39 11] Our system has detected that this message is not RFC 5322 compliant: Multiple 'From' headers found. To reduce the amount of spam sent to Gmail, this message has been blocked. Please visit https://support.google.com/mail/?p=RfcMessageNonCompliant and review RFC 5322 specifications for more information. h190si13823586ite.62 - gsmtp 

So the error is because it's IIS sending the email to sendgrid and because of that, it's beeing marked as a spam.

What could cause this?

Etienne Dupuis
  • 13,548
  • 6
  • 47
  • 58
  • 1
    It seems that IIS isn't just acting as a relay and is instead appending some headers. Is it possible to view the MIME message before and after it goes to IIS? Then you can isolate the problem to code or server. – bwest Nov 09 '16 at 19:18

1 Answers1

2

Apparently you need a detailed header when using PHP mail() and not when you telnet.

For PHP mail() at mininum:

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
$headers .= "From: your@email.com" . "\r\n";
Etienne Dupuis
  • 13,548
  • 6
  • 47
  • 58