1

I am trying to send mail through mail server ( available in fatcow).

Username:    [email protected]
SMTP Server:     smtp.hostname.com
SMTP Port:   587

I used the follwing code to send mail ,

 if (ModelState.IsValid)
 {
   MailMessage message = new MailMessage();
     try
        {
                message.To.Add(new MailAddress("[email protected]"));
                message.From = new MailAddress("[email protected]");
                message.Subject = "Test mail";
                message.Body = "this is the mail sended through my c#.net program";
                message.BodyEncoding = System.Text.Encoding.UTF8;
                message.SubjectEncoding = System.Text.Encoding.UTF8;

                SmtpClient client = new SmtpClient();
                client.Port = 587; 
                client.Host = "smtp.hostname.com";
                System.Net.NetworkCredential nc = new System.Net.NetworkCredential("[email protected]", "password");// is u are using Gmail
                client.EnableSsl = true;
                client.UseDefaultCredentials = false;
                client.Credentials = nc;
                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate);
                client.Send(message);
            }
            catch (Exception ex)
            {
                ;
            }
        }

When i use gmail server the code works fine and i received mail.

But it is not working with my email server.

I get the error,

the remote certificate is invalid according to the validation procedure

Is there anything left to do to make it work?

Please help,

Thank you

2
  • 1
    As first check I will suggest to check if your SSL certificate is correctly installed on your server Commented Dec 1, 2012 at 7:11
  • thank u..u r right...that was the problem... I can accept ur answer if u put it Commented Dec 1, 2012 at 7:36

1 Answer 1

1

As first check I will suggest to check if your SSL certificate is correctly installed on your server

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.