SMTP Mail Error - Requires Client Authentication

J

Jeff

I am receiving the following error:

// error: System.Net.Mail.SmtpException: The SMTP server requires a
secure connection or the client was not authenticated. The server
response was: 5.7.0 No AUTH command has been given.

How do I provide the Client Authentication with the code below.


private void SendEmail2()
{
/* create the email message */
MailMessage message = new mailMessage("(e-mail address removed)",
"(e-mail address removed)","Test email " +
DateTime.Today.ToString(),"body fo the message " );

/* create SMTP Client and add credentials */
SmtpClient smtpClient = new SmtpClient("smtp.domain.com");

/* Email with Authentication */
smtpClient.Credentials = new NetworkCredential("jwill",
"abcdef");
smtpClient.UseDefaultCredentials = false;
/*Send the message */
smtpClient.Send(message);

// error: System.Net.Mail.SmtpException: The SMTP server requires a
secure connection or the client was not authenticated. The server
response was: 5.7.0 No AUTH command has been given.
}
 
C

Claire

Hi, Ive not looked at your code too closely but the following is a clip from
my own email sending function which is tested and works ok.
If yours is similar then it may be that your smtp settings are incorrect


public bool SendEmail(
string SMTPHost, int SMTPPort, bool AuthenticationRequired,
string UserID, string Password, bool SSLRequired,
string Sender, string Recipient, string Subject, string Body,
string BCC,
tableMessagesEmailAttachments[] Attachments,
tableMessagesEmailAttachments[] Content,
bool IsHTML)
{

System.Net.Mail.MailMessage Message = new
System.Net.Mail.MailMessage(Sender, Recipient);

try
{
System.Net.Mail.SmtpClient MailClient = new System.Net.Mail.SmtpClient();
MailClient.Host = SMTPHost;
MailClient.Port = SMTPPort;
if (AuthenticationRequired)
{
System.Net.NetworkCredential Credentials = new
System.Net.NetworkCredential(UserID, Password);
MailClient.UseDefaultCredentials = false;
MailClient.Credentials = Credentials;
}
MailClient.EnableSsl = SSLRequired;
Message.Subject = Subject;
Message.IsBodyHtml = IsHTML;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top