You must Sign In to post a response.
  • Category: ASP.NET

    Error sending mail in


    I use the code below to send mail using yahoo smtp and ended up with error failed sending mail pl check the code and tell me where I went wrong

    public void sendMail()
    SmtpClient client = new SmtpClient();
    MailMessage message = new MailMessage();
    client.Port = 465;
    //client.Host = "";
    client.Host = "";//"";
    client.UseDefaultCredentials = true;
    client.Credentials = new System.Net.NetworkCredential("", "MyPassword");
    client.EnableSsl = true;
    MailAddress SendTo = new MailAddress("");
    // MailAddress SendTo = new MailAddress("");
    MailAddress SendFrom = new MailAddress("");
    message = new MailMessage(SendFrom, SendTo);
    message.Body = "Test Mail";
    message.Subject = "Test Mail";
    catch (Exception ex)

    and I get the error Failure Sending mail

    and the inner exception states "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host." It works well with but not with yahoo pl help me its very urgent .
  • #652225
    Change the Host name with below one
    * Incoming mail server (POP3):
    * Outgoing mail server (SMTP):

  • #652232
    The SMTP server you are using might not open to allow sending the mail,
    as there is nothing wrong in the code and you said that the code is working fine for the Gmail server.

    ping this server and check that this is open and responding.

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • #652311

    use smtp as its enough to send email and set enable ssl false. try like below code just placed from and to id below code to test working perfectly.

    protected void Button2_Click(object sender, EventArgs e)
    MailMessage msg = new MailMessage("", "", "subjectofmail", "mail body");
    msg.Body = "<b>Hello User</b>";
    SmtpClient mailClient = new SmtpClient("", 25); //Change your smtp name and port number
    NetworkCredential NetCrd = new NetworkCredential("", "frmidpwd");
    mailClient.UseDefaultCredentials = false;
    mailClient.Credentials = NetCrd;
    mailClient.EnableSsl = false;
    msg.IsBodyHtml = true;
    mailClient.DeliveryMethod = SmtpDeliveryMethod.Network;
    catch (Exception ex)

    Your Hard work never fails

  • #652347
    [Response removed by Admin. Read forum policies.]

  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.