我有一个简单的C#应用程序,该应用程序从“ noreply@domain.com”发送带有附件的电子邮件。如果我使用自己的电子邮件地址,则效果很好。其他电子邮件,结果错误。消息服务器团队无法解决,因为他们在config上的服务器设置中未发现任何问题。我的应用程序很简单,但是无法正常工作。这是代码。
ReportDocument cryRpt = new ReportDocument();
AutoTCs AutoTC = new AutoTCs();
AutoTC.DataSourceConnections[0].SetConnection(ConfigurationSettings.AppSettings["DBServer"], ConfigurationSettings.AppSettings["DBName"], ConfigurationSettings.AppSettings["DBUserId"], ConfigurationSettings.AppSettings["DBPwd"]);
//CredentialCache myCache = new CredentialCache();
Stream ms;
ms = (Stream)AutoTC.ExportToStream(ExportFormatType.PortableDocFormat);
Attachment attch = new Attachment(ms, "AutoTC_" + DateTime.Now.Month + "_" + DateTime.Now.Day + "_AM.pdf");
MailMessage emsg = new MailMessage(System.Configuration.ConfigurationSettings.AppSettings["FromAddress"], ConfigurationSettings.AppSettings["ToAddress"], "Auto TC Report " + DateTime.Now.Month + "/" + DateTime.Now.Day + " AM", "Please find the Auto TC report ");
string[] arInfo = new string[4];
// define which character is seperating fields
char[] splitter = { ';' };
arInfo = ConfigurationSettings.AppSettings["CCAddress"].ToString().Split(splitter);
for (int x = 0; x < arInfo.Length; x++)
{
emsg.CC.Add(arInfo[x]);
}
emsg.Attachments.Add(attch);
SmtpClient smtp = new SmtpClient(ConfigurationSettings.AppSettings["SMTP"]);
smtp.Port = 587;
smtp.UseDefaultCredentials = true;
//smtp.Credentials = CredentialCache.DefaultNetworkCredentials;
//smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Send(emsg);
在地址中,我只需输入“ noreply@noreply.domain.com”
给出此错误“邮箱不可用。服务器响应为5.7.1 客户端无权发送此发件人的权限”
我检查了其他端口25,但随后出现“通道未打开”类型的错误消息。