By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,659 Members | 1,714 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,659 IT Pros & Developers. It's quick & easy.

Send email problem when hosting

P: 4
Hi,

I rented a host. At localhost, i can control send email from this host to my email. However, when i hosting, it appears the below error:

The SMTP server requires a secure connection or the client was not authenticated. The server response was: host5.vdconline.vn ESMTP MailEnable Service, Version: 5.51-- denied access at 02/03/12 02:45:26

My code looks like:

Expand|Select|Wrap|Line Numbers
  1. if( dr != null)
  2.             dr.Close();
  3.         string mail = "select PassWord from UserTable where email = "+"'"+TextBox1.Text+"'";
  4.         cmd = new SqlCommand(mail, conn);
  5.         cmd.ExecuteNonQuery();
  6.         dr = cmd.ExecuteReader();
  7.         dr.Read();
  8.  
  9.         MailMessage msg = new MailMessage();
  10.         SmtpClient smtp = new SmtpClient("*.*.*.*", 25);        
  11.         msg.From = new MailAddress("*@*.*");        
  12.         msg.To.Add(new MailAddress(TextBox1.Text));
  13.         msg.Subject = "Recover password.";
  14.         msg.Body = "Your password: " + dr[0].ToString();
  15.         msg.IsBodyHtml = true;
  16.  
  17.         smtp.EnableSsl = true;      
  18.         smtp.UseDefaultCredentials = false;
  19.         smtp.Credentials = new NetworkCredential("*@*.*", "******");  
  20.         try
  21.         {
  22.             smtp.Send(msg);
  23.             Label3.Text = "Email sent successfully";
  24.         }
  25.         catch (Exception ex)
  26.         {
  27.             Label3.Text = ""+ex.Message;
  28.         }
  29.  
Thanks in advance!
Feb 3 '12 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.