当我要使用c#发送电子邮件时,smtpclient:“尝试通过此SMTP(提交)端口发送邮件时,此邮件服务器需要身份验证(1)” 在Windows Server 2008 R2服务器上收到错误。但是当我在自己的计算机(Windows 10)上尝试时,我没有任何问题。我尝试关闭防火墙,但没有解决方案。 Windows日志中没有错误。该服务器还安装了sharepoint2010。要通过共享点发送邮件,smtp服务器服务正在运行。这两个可以重叠吗? 我在哪里可以查看?
公共布尔SendMail() {
MailAddress SenderMailAddress = new MailAddress(GonderenEPosta, GonderenAdi == "" ? "" : GonderenAdi);
MailAddressCollection RecipientMailAdresses = ParseRecipients(Alicilar);
if (RecipientMailAdresses.Count==0)
{
Sonuc = "Mail Adresi Geçersiz";
hataKod = 1;
return false;
}
SmtpClient MailClient = new SmtpClient();
MailClient.Host = Server;
MailClient.DeliveryMethod = SmtpDeliveryMethod.Network;
MailClient.EnableSsl = SSL;
if (Port==0)
{
Port = 587;
}
MailClient.Port = Port;
NetworkCredential auth = new NetworkCredential();
if (Parola != "")
{
//auth = new NetworkCredential(GonderenEPosta, Parola);
MailClient.Credentials = new NetworkCredential(GonderenEPosta, Parola);
MailClient.UseDefaultCredentials = false;
}
else
{
MailClient.UseDefaultCredentials = true;
}
MailMessage Email = new MailMessage();
Email.IsBodyHtml = HTML;
Email.Subject = Konu;
Email.From = SenderMailAddress;
Email.Body = EPosta;
if (TeslimIste)
{
Email.DeliveryNotificationOptions =
DeliveryNotificationOptions.OnSuccess| DeliveryNotificationOptions.OnFailure | DeliveryNotificationOptions.Delay;
Email.Headers.Add("Disposition-Notification-To", GonderenEPosta);
}
if (OkunduIste)
{
Email.Headers.Add("Return-Receipt-To", GonderenEPosta);
Email.Headers.Add("Read-Receipt-To", GonderenEPosta);
}
if (!String.IsNullOrEmpty(UniqueID))
{
Email.Headers.Add("X-Yeniyol-ID", UniqueID);
}
foreach (MailAddress r in RecipientMailAdresses)
{
if (Gizli==true)
{
Email.Bcc.Add(r);
}
else
{
Email.To.Add(r);
}
}
for (int i = 0; i < EkDosyalar.Count; i++)
{
Email.Attachments.Add(new Attachment(EkDosyalar[i]));
}
bool resp = false;
try
{
ServicePointManager.ServerCertificateValidationCallback =
delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
};
MailClient.Send(Email);
Sonuc = "Gönderildi";
resp = true;
}
catch (Exception ex)
{
string msj = ex.Message;
if (ex.InnerException != null)
{
msj += ", İç hata:" + ex.InnerException.Message;
}
Sonuc = "Gönderilemedi : \n" + msj;
hataKod = 2;
}
MailClient = null;
return resp;
}
答案 0 :(得分:0)
好的,我发现了问题。 3天前,我们更新了邮件服务器。 mail.XXXXX.com地址未更改,但IP地址已更改。因此,应该在邮件发送服务器上完成DNS地址交换。 我已经修复了DNS服务菜单中出现在mail.XXXX.com上的IP地址,问题已解决。
:)