Search code examples
c#smtphmail-server

Cant connect/send from hMailServer


I have recently setup hMailServer.

I have a domain on godaddy so I am using the MX record given by godaddy. For this example, I am going to say that I am using mail.hmailserver.net as the MX Record.

I have added the username and password under SETTINGS > Protocols > SMTP on hMailServer Administrator, and so I have the following configured.

enter image description here

I have added an "inbound" firewall rule that opens up Port 25 to make sure that the port is not being blocked.

I can ping my MX record and it will resolve the IP fine, but yet if I try to use the following telnet command, I am unable to connect

telnet mail.hmailserver.net 25

It tells me it is unable to connect.

Initially I was using a simple client application to test this, and I believed it might have been in my code that was causing the problem, but now I am thinking I have something configured incorrectly.

public static void Main(string[] args)
{
    MailMessage message = new MailMessage();
    message.From = new MailAddress("[email protected]");
    message.To.Add("[email protected]");

    message.Subject = "Test Subject";
    message.Body = "Test Body";

    SmtpClient client = new SmtpClient();
    client.Host = "mail.hmailserver.net";
    client.Port = 25;

    NetworkCredential login = new NetworkCredential("Administrator", "Password");
    client.Credentials = login;

    try
    {
        client.Send(message);
    }
    catch (Exception exception)
    {
        Console.WriteLine(exception.Message);
    }
}

Any ideas if I am doing it incorrectly from the screenshot above? Eventually this will be sending emails from a hosted application in IIS, I am not sure if that makes a difference.

Please Help.


Solution

  • Maybe your provider has blocked outbound traffic to other SMTP servers than the server of your provider?

    Find your providers SMTP server address and test it with that address.