Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I am getting an Error while sending Email from Asp.net page "Server does not support secure connections".

my code is

{
        string from = "frommail";
        string to ="tomail";
        string Password = "password";
        int port = Convert.ToInt32(ConfigurationManager.AppSettings["port"]);
        string smtp = Convert.ToString(ConfigurationManager.AppSettings["smtp"]);
        string Subject ="Enquiry";
        string body ="Sender Name :"+txtname.Text+"\n"+
                     "Phone :"+txtphone.Text+"\n"+
                     "Email :"+txtemail.Text+"\n"+
                     "Address :"+txtaddress.Text+"\n"
                     +"Enquiry :"+txtenquiry.Text;
        MailMessage Msg = new MailMessage(from, to, Subject, body);
        //Smtp Host is the  name or Ip host of the computer used for sending mail
        SmtpClient smtpobj = new SmtpClient("smtp.rediffmailpro.com",587);
        smtpobj.Host = "smtp.rediffmailpro.com";
        smtpobj.Port =587;
        smtpobj.EnableSsl = true;
        smtpobj.UseDefaultCredentials = true;
        smtpobj.Credentials = new System.Net.NetworkCredential(from,Password);
       
        try
        {
            smtpobj.Send(Msg);
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "ASET", "<script type='text/javascript'>alert('Your Message Has Been Send ');</script>", false);
            CleaContents();
        }
        catch (Exception ex)
        {
            lbltext.Text = ex.Message;
        }
        
    }


---------------------

while giving gmail mail id and gmail smtp its working but when using rediffmail and smtp its getting message like Server does not support secure connections.
Posted
Updated 13-Jul-17 1:03am
v2

Try changing the port number to 25 instead of 587 . 587 is for gmail account and rediffmail uses 25. Also , check the smtpobj.UseDefaultCredentials value, if its secure connection then you need to set it false and provide username and password associated with the account.

Refer

http://enlook.wordpress.com/techs-and-tips-you-finding/mail-server-settings-for-hotmail-yahoo-mail-gmail-msn-aol-and-more/[^]

Hope this helps...
 
Share this answer
 
C#
smtpobj.EnableSsl = false
;

Use this one
 
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