Click here to Skip to main content
15,887,421 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to configure mail using c#.
Here is my code; i am getting the above error.
Please help me to solve this.

public bool Send()
    {
        string user = ConfigurationManager.AppSettings["email_username"].ToString();
        string password = ConfigurationManager.AppSettings["email_password"].ToString();
        SmtpClient SmtpServer = new SmtpClient();
        SmtpServer.Credentials = new System.Net.NetworkCredential(user, password);
	SmtpServer.Port = 25;
	SmtpServer.Host = "smtp.rediffmail.com";
        SmtpServer.EnableSsl = true;
        MailMessage mail = new MailMessage();
        try
        {

            mail.From = new MailAddress(user, "SUBJECT", System.Text.Encoding.UTF8);
            mail.To.Add(new MailAddress(to));
            mail.Subject = subject;
            mail.Body = message;
            mail.IsBodyHtml = true;
            mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
            mail.ReplyTo = new MailAddress(frm);
            SmtpServer.Send(mail);

        }
        catch (Exception err)
        {	
	return false;
	}
	return true;
    }


Thanks in advance
Posted

Hi
Please change the
C#
SmtpServer.EnableSsl = true;

into
C#
SmtpServer.EnableSsl = false;


Your server seems SSL is not configure for secure connection. Changing above code, mail should start out going.


Thanks
Ashutosh Srivastava
 
Share this answer
 
Comments
Member 10191741 11-Aug-13 14:39pm    
thank you so much
kailas83 23-Nov-16 0:28am    
Thanks Ashutosh
It has also been my problem before and the reason is due to restrictions on my smtp server. Contact your network admin and ask for assistance.

In your case it could also be due to host and port issues.

Best regards,
Eduard
 
Share this answer
 
v2
Comments
ShortProgrammer 15-Jul-13 3:17am    
Server Error in '/' Application. Server does not support secure connections.
SmtpServer.Port = 25;
you wiil use gmail account to send mail,bcoz no smtp problems .try it and then test ur rediff accounts.k
 
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