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

    Error:Server does not support secure connections

    i am done a work for dens a mail with multiple attachments.

    i have done it and it's working fine on local only with default (smtp.gmail.com,port-587)credentials.

    but it does not working on live. it is hosted when i am try to send mail with attachments i got error something like SERVER DOES NOT SUPPORT SECURE CONNECTIONS.

    so help me friends for i am resolve this error.

    below is am adding my source code,


    protected void btnSend_Click(object sender, EventArgs e)
    {

    MailMessage mailmesssage = new MailMessage();
    mailmesssage.From = new MailAddress("sender@gmail.com", "Paul Raj");
    mailmesssage.To.Add("receiver@gmail.com");
    mailmesssage.Subject = "Details";

    if (FileUpload1.HasFile)
    {
    foreach (var file in FileUpload1.PostedFiles)
    {
    string fn = file.FileName;
    mailmesssage.Attachments.Add(new Attachment(file.InputStream, fn));
    }
    }
    if (FileUpload2.HasFile)
    {
    foreach (var file1 in FileUpload2.PostedFiles)
    {
    string fn1 = file1.FileName;
    mailmesssage.Attachments.Add(new Attachment(file1.InputStream, fn1));
    }
    }

    //G-mail settings
    try
    {

    SmtpClient smtpClient = new SmtpClient("smtp.gmail.com");
    smtpClient.Port = 587;
    smtpClient.Credentials = new NetworkCredential("sender@gmail.com", "password");
    smtpClient.EnableSsl = true;
    smtpClient.Send(mailmesssage);
    mailmesssage.Attachments.Clear();
    MsgBox("Hello Mr." + txtname.Text.Trim().ToString() + Environment.NewLine + " your Attachments has been Sent Successfully..", this.Page, this);

    }
    catch (Exception ex)
    {
    Response.Write("<script>alert('" + Server.HtmlEncode(ex.Message) + "')</script>");
    }
    }

    Thanks with
    Paul.S
  • #763583
    Did you try the following?


    smtpClient.EnableSsl = false;

    By Nathan
    Direction is important than speed

  • #763584
    It looks, Your server seems SSL is not configure for secure connection. Changing above code, mail should start out going.
    change your code to make enablessl to false
    see below snippet

    SmtpServer.EnableSsl = false;

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #763586
    Yes nathan ,

    but nothing to change i got the same error.
    like smtp server does not support secure connections.

    thanks with
    Paul.S

  • #763609

    If you want to send a secure mail with 'ssl' enable then
    you need to Enable SSL on your AuthSMTP account for that simply need to login to the Control Panel, go to the 'Advanced Config' tab and toggle the option, when ssl is enable it uses port 465 and additionally you need to use ClientCertificates to specify which client certificates should be used to establish the SSL connection, for more information about ssl check out below links
    https://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.enablessl(v=vs.110).aspx


    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]


Sign In to post your comments