系统发送邮件使用SMTP IP地址发送时,发送失败!
备注:SMTP不用帐号密码验证,但不允许匿名发送
以下C#代码使用SMTP服务器发送正常
private string Send(string Body, string Mailto, string CCMailto, string Title)
{
try
{
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(sSmtpMailFrom, Mailto, Title, Body + SendPS);
message.SubjectEncoding = System.Text.Encoding.UTF8;/
message.BodyEncoding = System.Text.Encoding.UTF8;
message.IsBodyHtml = true;
message.Priority = MailPriority.High;
if (CCMailto.Length > 0)
{
message.CC.Add(CCMailto);
}
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(sSmtpIP, sSmtpPort);
client.UseDefaultCredentials = false;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Send(message);
return "Success";
}
catch (Exception exp)
{
return exp.Message;
}
}
|