Sending mail using C #

I installed my hMailServer on my Windows 2008 computer and I'm trying to send emails.

When I do this using C #

MailMessage message = new MailMessage();
message.From = new MailAddress(from, "John");
message.To.Add(new MailAddress(to));
message.Subject = subject;
message.Body = body;
SmtpClient client = new SmtpClient("mail.example.com");
client.Credentials = new System.Net.NetworkCredential("john@example.com", "password");
client.Send(message);

But when I try to send emails using the Windows Live email client, it gives me an error

Could not connect to server

All settings are the same. I tried several email clients, but it does not work. This has never happened to me before. I just switched from one machine to another and got this problem.

I can receive mail on the client though ...

+3
source share
1 answer

Try installing telnet on port 25, can it connect?

Open a command prompt:

telnet mail.example.com 25

( , ), , , . (, , , SMTP )

+3

Source: https://habr.com/ru/post/1740193/


All Articles