I want to send an email from my domain address in C#, but I get an error.
This is my code:
var smtp = new SmtpClient
{
Host = "webmail.myDomain.gov.sa",
Port = 25,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential("test@myDomain.gov.as", "12345678")
};
var smtp = new SmtpClient
{
Host = "webmail.myDomain.gov.sa",
Port = 25,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential("test@myDomain.gov.as", "12345678")
};
var mess = new MailMessage(senderAddress, receiverAddress)
{
Subject = message.Subject,
Body = message.Body,
IsBodyHtml = true
};
if (isAttach)
{
mess.Attachments.Add(new Attachment(message.Attachment));
}
smtp.Send(mess);
I get this error:
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 91.195.89.155:25
What I have tried:
I think it is because of security issue in host server maybe?