简体   繁体   中英

Can't send email using SMTP

I'm trying to send an email via .net smtp. I am receiving this message: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated

MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("server", 587);
SmtpServer.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
SmtpServer.UseDefaultCredentials = false;
SmtpServer.EnableSsl = false;
SmtpServer.Credentials = new   System.Net.NetworkCredential("username", "password");

mail.From = new MailAddress(FromMail);
mail.To.Add("emailaddress");
mail.Bcc.Add("emailaddress");
mail.Subject = subject;
mail.Body = body;
mail.IsBodyHtml = true;
SmtpServer.Send(mail);

The issue I believe is that the servers are located in the DMZ...anyone have any insight on how to fix this? If we assign the user with domain admin rights, the emails work...due to security reasons we don't want to go that route.

Issue resolved...the network team didn't have port 587 available...once they added it, emails started working for anonymous sender. I no longer need to use credentials. Thanks to all who replied.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM