Click here to Skip to main content
15,922,407 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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 74.125.200.108:587
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Sockets.SocketException: 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 74.125.200.108:587

Source Error:


Line 138:
Line 139: smtp.EnableSsl = true;
Line 140: smtp.Send(mail);
Line 141: ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Email Sent Successfully.');", true);
Line 142: }
Posted
Comments
F-ES Sitecore 13-Aug-15 6:23am    
The error is self-explanatory. Either there is no smtp server listening on that port at that address, it is not running properly, or there is a network\firewall issue between your webserver and the smtp server. Either way it's network or configuration, not code. Contact the people responsible for the smtp server and ask if there is anything specific you need to do such as authenticate etc, use ssl etc and have your code match what the server needs.

1 solution

Try below code to send mail using gmail.

C#
public string senMail(string emailId, string MailBody)
        {
            try
            {
                MailMessage mail = new MailMessage();
                SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); //Gmail SMTP Client

                mail.From = new MailAddress("abc@gmail.com"); //Sender email ID 
                mail.To.Add(emailId);
                mail.Subject = "Email Subject";
                mail.Body = mailBody;
 
                SmtpServer.Port = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential("abc@gmail.com", "abc152wte.7"); //Sender email and password (login credential)
                SmtpServer.EnableSsl = true;
                SmtpServer.Send(mail);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            return "";
        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900