Sending email directly using MailKit

391 Views Asked by At

All the examples I've seen on using MimeKit/MailKit to send an email has the SMTP client logging into a SMTP server and sending the email through that server. Is it possible to have MimeKit/MailKit send the email directly to the recipient?

In other words, if my app wishes to send an email to [email protected], is it possible to get the MailKit SMTP client to communicate directly to the SMTP server at hisdomain.com and send the email without having to go through my SMTP server? Or, if I have an app programmed to send me the daily whatever, to send the email to my SMTP server without having to actually log into the SMTP server.

1

There are 1 best solutions below

0
jstedfast On

Sure, it's possible to get MailKit to connect directly to hisdomain.com to send an email, but you need to tell MailKit to connect to hisdomain.com's SMTP server/port.

To do that, you'll need to find a suitable DNS library and query the MX records for hisdomain.com to figure out what the mail server hostname/ip is and what port to connect to, etc.

Once you have that information, you can tell MailKit to connect directly to that SMTP server and send the message.