Search code examples
c#emailsmtp

mailersend smtp relay setup with c#


i am trying to send an email with c# using the mailersend smtp service

i have set the SFP, DKIM, and return path dns records and everything is verified

also i have enabled the smtp service on the dashboard

but i get an error on sending :

Recipient domain must match senders domain

here my code:

var @from = "[email protected]"; //this match the registred domain, note that is a subdomain ad not a tld
var to = "someemailadress";
var subject = "test lab";
var body = "it works !!!!";

var username = "myusername"; // get from Mailtrap
var password = "mypass"; // get from Mailtrap

var host = "smtp.mailersend.net";
var port = 587;

var client = new SmtpClient(host, port)
{
    Credentials = new NetworkCredential(username, password),
    EnableSsl = true
};

client.Send(@from, to, subject, body);

any idea on how to fix it DNS records


Solution

  • Yes, you should ask to be approved so your domain isn't limited. While pending approval, your domain can only send to recipients from the same domain, so mailersend.com can only send to [email protected].

    For detailed info follow the instructions here.