Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to resolve the error "The server response was: 5.5.1 Authentication Required"

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 300
    Comment on it

    Sometime the email is sending on local machine but not on the server machine it gives the error "The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required" To resolve these we add the 2 lines extra for sending email using gmail 1.smtpClient.UseDefaultCredentials = false;
    2.smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network

    Here below is the complete code for sending email using gmail

    public static bool SendEmail(string emailAddress, string bodyMessage, string Subject)
      {
    smtpClient = new SmtpClient();
    smtpClient.Host = "smtp.gmail.com";
    smtpClient.Port = 587;    
    message = new MailMessage();
    message.IsBodyHtml = true;
    smtpClient.UseDefaultCredentials = false;
    smtpClient.Credentials = new NetworkCredential("Username", "pwd");
    smtpClient.EnableSsl = true;
    message.From = new MailAddress("emailfromaddress", "emailheader");
    message.Body = bodyMessage;
    message.Subject = Subject;
    message.To.Add(emailAddress);
    smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
    smtpClient.Send(message);
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: