I try to make an email service in my project using Gmail SMTP, but when the Socket connection start 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 64.233.166.109:25"
This is a part of the code:
private static string SmtpServer = "smtp.gmail.com";
private enum SMTPResponse : int
{
CONNECT_SUCCESS = 220,
GENERIC_SUCCESS = 250,
DATA_SUCCESS = 354,
QUIT_SUCCESS = 221
}
public static bool Send(MailMessage message)
{
IPHostEntry IPhst = Dns.GetHostEntry(SmtpServer);
IPEndPoint endPt = new IPEndPoint(IPhst.AddressList[0], 25);
Socket s = new Socket(endPt.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
s.Connect(endPt);
}