We upgraded a customer shop from v4.30 to v4.40.3. Now, eMails with attachments (e.g. the "OrderCompleted.CustomerNotification" template) sent from the system get bounced back with the following SMTP Error:
Remote Server returned '550 5.6.11 SMTPSEND.BareLinefeedsAreIllegal; message contains bare linefeeds, which cannot be sent via DATA and receiving system does not support BDAT'
We haven't changed the eMail-Templates nor the eMail server.
We can also confirm, that bevore the upgrade one of the customers got all eMails delivered and the same customer (same eMail address) doesn't get the eMails now.
The only change was the switch from 4.30 (.NET Framework) to 4.40.3 (.NET Core).
So, there must be a change in the way eMails with attachments are handeld in nopCommerce 4.40.x.
For now, only eMails with attachments will not be delivered.
Any clue what we can do to get the eMails working again?
Thank you, Christian
I have no answer for you but can confirm this is a production issue for our implementation as well. Just upgraded last night and battling this issue all day today. Same conclusion.
The "test" Template function within the template designer works just fine. once a file is added, it will not deliver to some of our sub-domain users.
hope we get a response from the nop team soon.
So ..... three weeks are gone an nobody has a solution for such a major problem?
No comment from the nopCommerce team? Really?
I mean, are we the only company which sends correct invoices to customers ....?
After no one wants to help me, I have to help myself. ;-)
The problem is the used MailKit NuGet package and the non conform usage of it.
You need to add the bold marked line in the following code.
Then attachments are correctly encoded and the problem is gone.
/// Create an file attachment for the binary data
/// <param name="attachmentFileName">Attachment file name</param>
/// <param name="binaryContent">The array of unsigned bytes from which to create the attachment stream.</param>
/// <param name="cDate">Creation date and time for the specified file or directory</param>
/// <param name="mDate">Date and time that the specified file or directory was last written to</param>
/// <param name="rDate">Date and time that the specified file or directory was last access to.</param>
/// <returns>A leaf-node MIME part that contains an attachment.</returns>
protected MimePart CreateMimeAttachment(string attachmentFileName, byte binaryContent, DateTime cDate, DateTime mDate, DateTime rDate)
if (!ContentType.TryParse(MimeTypes.GetMimeType(attachmentFileName), out var mimeContentType))
mimeContentType = new ContentType("application", "octet-stream");
return new MimePart(mimeContentType)
FileName = attachmentFileName,
Content = new MimeContent(new MemoryStream(binaryContent)),
ContentDisposition = new ContentDisposition
CreationDate = cDate,
ModificationDate = mDate,
ReadDate = rDate
// Solves: Remote Server returned '550 5.6.11 SMTPSEND.BareLinefeedsAreIllegal; message contains bare linefeeds, which cannot be sent via DATA and receiving system does not support BDAT'
ContentTransferEncoding = ContentEncoding.Base64