Skip to content

Option to opt out of message Prepare in SmtpClient.SendAsync #891

Description

@nitinag

We're looking at using MimeKit to accept incoming messages and forward/relay them.

During forward/relay, we would like the option to force enable 8BITMIME after connect (recommended at https://cr.yp.to/smtp/8bitmime.html and other places), but because SmtpClient.Capabilities does not allow enabling capabilities, this is not currently possible. I could also see it useful to force enable PIPELINING for testing. We're going to be forwarding messages (many DKIM signed) and thus would want messages to stay in exactly the same source format regardless of destination server supporting 8BITMIME or not. This does raise the issue of BODY being added to MAIL FROM when 8BITMIME is not advertised, which I guess we'd not want to be added either if the server doesn't advertise it, but we'd still want to send as 8BITMIME. That may thus require a different solution, but I feel enabling capabilities is still useful.

Given we're forwarding DKIM signed messages, we'll want to add a few headers on top and send the remaining message as is. Can we expect MailKit/MimeKit to not modify the message/headers/body other than the few headers we explicitly add during SendAsync? What about MimeMessage.WriteTo?

I'm aware we'll need to clear MimeKit.FormatOptions.HiddenHeaders. Possibly set some of the other FormatOptions? What about Body.Prepare done inside of SmtpClient.SendAsync? Or should we just consider sending the messages directly from the raw file, add our headers on top manually, using our own tcp stream (maybe after using MailKit to handle the initial connection)?

I'd also like to suggest adding a methods to send a custom commands in SmtpClient. Though I guess one could just pass their own tcp stream and send/read a custom command when necessary, but then they'd need to parse/handle the smtp response.

We'll be using the persistent flag as well for lower memory usage during sending.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionA question about how to do something

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions