Different MIME and SMTP from addresses

£可爱£侵袭症+ 提交于 2020-01-05 09:32:17

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!