2012-04-11 2 views
0

Я получаю следующее сообщение об ошибке при отправке электронной почты с помощью gmailD.Ошибка при отправке электронной почты с помощью GmailD

Для SMTP-сервера требуется безопасное соединение, или клиент не прошел аутентификацию. Ответ сервера: 5.5.1 Требуется аутентификация.

MailMessage objMailMessage = new MailMessage(); 
     objMailMessage.From = new MailAddress("[email protected]"); 
     objMailMessage.To.Add(new MailAddress("[email protected]")); 
     objMailMessage.Subject = "Test"; 
     objMailMessage.Body = "Test Test"; 
     objMailMessage.IsBodyHtml = true; 

     SmtpClient smtpClient = new SmtpClient(); 
     smtpClient.Host = "smtp.gmail.com"; 
     smtpClient.Port = 587;   
     smtpClient.EnableSsl = true; 
     smtpClient.UseDefaultCredentials = false;   
     smtpClient.Credentials = new System.Net.NetworkCredential("[email protected]", "password"); 
     smtpClient.Send(objMailMessage); 
+0

Вы уверены, что ваш адрес электронной почты и пароль в настоящее время установлены правильно? –

ответ

0

Попробуйте изменить порт 465

  SmtpMail oMail = new SmtpMail("TryIt"); 
      SmtpClient oSmtp = new SmtpClient(); 

      // Your gmail email address 
      oMail.From = "[email protected]"; 

      // Set recipient email address 
      oMail.To = "[email protected]"; 

      // Set email subject 
      oMail.Subject = "test email from gmail account"; 

      // Set email body 
      oMail.TextBody = "this is a test email sent from c# project with gmail."; 

      // Gmail SMTP server address 
      SmtpServer oServer = new SmtpServer("smtp.gmail.com"); 

      // If you want to use direct SSL 465 port, 
      // please add this line, otherwise TLS will be used. 
      // oServer.Port = 465; 

      // detect SSL/TLS automatically 
      oServer.ConnectType = SmtpConnectType.ConnectSSLAuto; 

      // Gmail user authentication 
      // For example: your email is "[email protected]", then the user should be the same 
      oServer.User = "[email protected]"; 
      oServer.Password = "yourpassword"; 

проверки ссылке ниже: http://www.emailarchitect.net/easendmail/kb/csharp.aspx?cat=2

Смежные вопросы