+1 vote
by (140 points)

I'm experiencing a problem while trying to send emails through Office 365 using the Rebex smtp library.

The problem is that gmail is rejecting messages with the following:
"550-5.7.1 [207.46.100.64 11] Our system has detected that this message is 550-5.7.1 not RFC 2822 compliant. To reduce the amount of spam sent to Gmail, 550-5.7.1 this message has been blocked. Please review 550 5.7.1 RFC 2822 specifications for more information. c75si2207109oig.1 - gsmtp"

However, I am able to use the Rebex smtp to successfully send to gmail recipients so long as I don't pass through Office 365.

Additionally, I am able to successfully send to gmail recipients through Office 365 if I use the standard .NET smtp client.

Is there any advice you can offer?

Applies to: Rebex Secure Mail

1 Answer

0 votes
by (148k points)
edited by

Unfortunately, there are multiple possible causes of this issue (see this or this, for example). They include from bad characters in From or To headers, duplicate From or To headers or missing Date header. Office 365 is based on Microsoft Exchange which does all kind of processing on messages it transmit, so it's quite possible that some aspect of MIME messages produced by Rebex Secure Mail could trigger some behavior at the server that results in Gmail rejecting the message.

However, the fact that it's a combination of Rebex Secure Mail and Office 365 makes this particular case difficult to analyze. Could you please save one of the messages that trigger this issue to a file (using MailMessage or MimeMessage object's Save method), open it using a text editor (such as Notepad) and post its headers (or mail them to support@rebex.net) for analysis? If we could reproduce the issue, we might be able to quickly solve it as well. Thanks!

Update: In the meantime, we tried sending a simple e-mail message through Office 365 to Gmail and this works without issues:

static void Main(string[] args)
{
         string from = "Tester <tester@rebexcz.onmicrosoft.com>";
         string to = "Rebex Test <rebex.test@gmail.com>, Rebex Support <support@rebex.net>";
         string subject = "From Office 365 to GMail.";
         string body = "Sample body\r\nFlow:\r\n\tOffice 365 -> GMail.";

         string username = "tester@rebexcz.onmicrosoft.com";
         string password = ...;

         var mail = new MailMessage();
         mail.From = from;
         mail.To = to;
         mail.Subject = subject;
         mail.BodyText = body;

         using (var smtp = new Smtp())
         {
                 smtp.Connect("outlook.office365.com", SslMode.Explicit);
                 smtp.Login(username, password);
                 smtp.Send(mail);
                 smtp.Disconnect();
         }
}
by (140 points)
I may have located the issue, but haven't verified the result with Office 365. Here is the header:

Message-ID: <55b1d500d7d4ca677c9d6de773e1bcbb@dburton>
Date: Mon, 2 Nov 2015 10:38:09 -0600
Subject: Sanity Clean
Sender: "sa" <sa@sa.com>
To: "ALLISON CHAINS" <someone@gmail.com>
MIME-Version: 1.0
Content-Type: multipart/alternative;
    boundary="------_=_NextPart_001_DC307E6D.A8FF3AC9"

This is a multipart MIME message.

Note that I have set "Sender" instead of "From". Just a mistake on my part due to the way my variables were named. My code looks  nearly identical to your's above, except for the fact that I set "Sender".

This is not RFC compliant. Though I find it interesting that it will be let through by gmail under certain circumstances. I will change my code to correctly use "From" instead and see how that goes.
by (140 points)
So, I'm finally getting around to following up with this. The use of "Sender" instead of "From" was in fact the problem.

Thanks for checking, guys.
by (148k points)
Thanks for getting back to us and letting us know!
...