dmcgiv / DKIM.Net

DomainKeys Identified Mail (DKIM) and DomainKey email signing for .Net (C#)
31 stars 9 forks source link

Emails with AlternateViews #3

Open brendanmckenzie opened 12 years ago

brendanmckenzie commented 12 years ago

Hello,

Was wondering if you've had any thoughts on how to address the issue with messages that have Alternate Views?

Brendan

dmcgiv commented 12 years ago

DKIM.Net hacks the sending process to get the formatted text so that it can sign the formatted text - attempting to sign the text before formatting would result in an invalid signing. For this to work the formatting process needs to be deterministic - getting the same output every time you use the same input. Unfortunately the formatting process in System.Net.MailWriter is only deterministic if boundaries are not used as the boundary is set to a new Guid each time. Alternative Views and attachments use boundaries and so therefore it's not possible to sign such emails with this code.

The only workaround is to use this code to sign the email and then use another means to send the email other then the built in SMTP client. You could use Amazon's SES service (which I originally wrote the code for) or an alternative .Net SMPT component that allows you to write raw streams.