Cannot send emails from C# code to any other domain but mine

Discussion in 'Email' started by nicom72, Jan 6, 2014.

  1. Hi,
    it seems I can send emails from my C# code only to email addresses hosted on my own domain, but not to other domains such as gmail or hotmail. Although I can send emails to any address from the SmarterMail web client on and from Windows Live Mail (running on my local machine).
    I already went through all the forum entries and couldn't find a solution.
    My DNS configuration for that can be found at: is:

    A Record for mail domain:

    Domain Name:
    IP Address: AAA.BBB.CCC.DDD
    TTL: 3600

    When this IP address is copied-and-pasted in a web browser, it resolves to the web page login of SmarterMail on

    There are two more A record for "" and "" which resolve to another IP address.

    MX Record:

    Domain Name:
    Mail Server:
    Priority: 10
    TTL: 3600

    No other MX Records exist.

    My C# test code (running from my local machine) is:

    // GIVEN
    // Works fine with "" email addresses such as "[email protected]"
    // Doesn't work with email addresses not hosted on "" such as,, ...
    // Of course "" here is just a placeholder for the actual domain name which is embedded in my real code.
    var recipientEmailAddress = "[email protected]"; // In my actual code I use an existing email address, the one showed here is just a placeholder.

    var msg = new MailMessage
    BodyEncoding = Encoding.Default,
    IsBodyHtml = true,
    Subject = emailSubject,
    Body = emailHtmlBody,
    From = new MailAddress("[email protected]"),
    msg.To.Add(new MailAddress(recipientEmailAddress));

    var smtpClient = new SmtpClient("") // nothing changes if I use the MX record to which points to:
    Credentials = new NetworkCredential("[email protected]", "postmaster password"),
    DeliveryMethod = SmtpDeliveryMethod.Network,
    Port = 587, // also tried 25 and 465, but they don't seem to work
    Timeout = 60000,
    UseDefaultCredentials = false,

    // WHEN-THEN

    Hangs for a few seconds then throws the exception:

    System.Net.Mail.SmtpFailedRecipientException: Mailbox not available. The server answered: <[email protected]> No such user here

    What am I doing wrong?

    Thank you for your help.
    Last edited by a moderator: Oct 14, 2015
  2. Elshadriel

    Elshadriel Winhost Staff

    You probably need to add a line of code for SMTP authentication. We provide sample code in this Knowledge Base article.
    Last edited by a moderator: Oct 14, 2015
  3. Hi,
    thank you for your reply. I followed your example in the Knowledge Base when I wrote the code I posted here.
    Isn't SMTP authentication taken care of by the NetworkCredential instance where I pass the postmaster username and password?
    Thank you.
  4. Elshadriel

    Elshadriel Winhost Staff

    You might also need to enable "Full Trust" as described in this Knowledge Base article. If this doesn't work, you can either message me your domain name so I can take a closer look or open up a support ticket regarding the problem. In either case, please provide us with a screen shot of the full error and a way to reproduce the problem. Everything looks ok so far.
    Last edited by a moderator: Oct 14, 2015
  5. I'm running a .Net 4.5 console application which will become a windows service on Azure, so I couldn't set the full trust level as mentioned in your KB. I found another way and now it's full trust.
    The problem remains, so I'm sending you a private message.
    Thank you for your time and effort.
  6. Hi I am having the same problem on, what was the resolution of this please?
  7. Hi Michael, thanks, but as it happens it was a coding error on my part, so it is resolved
    Michael and Elshadriel like this.

Share This Page