问题
Is there a way I can send an email with a different mime and smtp address? The MailMessage does not seem to support this.
回答1:
What Kevin is talking about is that he wants the message itself to contain a different set of addresses in the headers than who the message is actually sent from (or to).
For example, in the message headers, you might have:
From: jack@thehill.com
But you might connect to the SMTP server and use jill@thehill.com
.
This can be useful if you have an alias set up that simply redirects to your other address but the SMTP server will only accept messages sent from an email address in its own domain (I think GMail has this restriction).
It's also useful when sending to undisclosed recipients.
That said... you may want to look into using my MimeKit and MailKit libraries for .NET.
MimeKit handles constructing and parsing of email messages while MailKit has all of the logic for SMTP, POP3, and IMAP.
What you can do is construct the MimeMessage with any email addresses that you'd like and then use:
client.Send (MimeMessage message, MailboxAddress sender, IEnumerable<MailboxAddress> recipients);
Hope that helps.
来源:https://stackoverflow.com/questions/27543333/different-mime-and-smtp-from-addresses