Sometimes sending mails using an SMTP server is not feasible for a project’s requirement. We may want to utilize the MX record of the recipient’s domain name. Following is a quick sample that shows how to send mails using mail servers of recipient’t domain.
[C#]
MailMessage msg = new MailMessage();
msg.From = "sender@mail.com";
msg.To = "use1@mail.com;user2@mail.com";
msg.Subject = "dns sending";
msg.Body = "it is a test.";
DnsMailClient client = new DnsMailClient();
client.Send(msg);
[VB.NET]
Dim msg As MailMessage = New MailMessage()
msg.From = "sender@mail.com"
msg.To = "use1@mail.com;user2@mail.com"
msg.Subject = "dns sending"
msg.Body = "it is a test."
Dim client As DnsMailClient = New DnsMailClient()
client.Send(msg)