Send email problem when hosting

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • blck
    New Member
    • Feb 2012
    • 4

    Send email problem when hosting

    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:

    Code:
    if( dr != null)
                dr.Close();
            string mail = "select PassWord from UserTable where email = "+"'"+TextBox1.Text+"'";
            cmd = new SqlCommand(mail, conn);
            cmd.ExecuteNonQuery();
            dr = cmd.ExecuteReader();
            dr.Read();
            
            MailMessage msg = new MailMessage();
            SmtpClient smtp = new SmtpClient("*.*.*.*", 25);        
            msg.From = new MailAddress("*@*.*");        
            msg.To.Add(new MailAddress(TextBox1.Text));
            msg.Subject = "Recover password.";
            msg.Body = "Your password: " + dr[0].ToString();
            msg.IsBodyHtml = true;
                            
            smtp.EnableSsl = true;      
            smtp.UseDefaultCredentials = false;
            smtp.Credentials = new NetworkCredential("*@*.*", "******");  
            try
            {
                smtp.Send(msg);
                Label3.Text = "Email sent successfully";
            }
            catch (Exception ex)
            {
                Label3.Text = ""+ex.Message;
            }
    Thanks in advance!
Working...