This commit is contained in:
2025-04-01 10:51:20 +08:00
parent 1e855681c8
commit 0a71c7d118
3 changed files with 20 additions and 16 deletions
+8 -4
View File
@@ -184,11 +184,10 @@ namespace BLL
mail.Body = bodyStr;
PushEmail(mail);
bool send= PushEmail(mail);
}
}
}
}
#endregion
@@ -203,29 +202,34 @@ namespace BLL
/// 发送邮件
/// </summary>
/// <param name="mail"></param>
private static void PushEmail(MailMessage mail)
private static bool PushEmail(MailMessage mail)
{
//获取发送邮箱配置
Email_Pop pops = BLL.Email_PopService.GetEmail_Pop("7EC5E991-B7A0-495A-90ED-2BE15370C959");
if (pops != null)
{
mail.From = new MailAddress(pops.EmailYx);//发件人邮箱地址
SmtpClient client = new SmtpClient(pops.EmailFwq);//替换为你的SMTP服务器地址
client.Port = int.Parse(pops.EmailDk);//587或465如果使用SSL
client.EnableSsl = true;//如果服务器支持SSL,设置为true
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential(pops.EmailYx, pops.EmailPass);//替换为你的邮箱和服务授权码
mail.From = new MailAddress(pops.EmailYx);//发件人邮箱地址
//client.Timeout = 6000; //6秒超时
try
{
client.Send(mail);
client.Dispose(); //释放资源
return true;
//Console.WriteLine("Email sent successfully.");
}
catch (Exception ex)
{
return false;
//Console.WriteLine("Email sending failed: " + ex.Message);
}
}
return false;
}
}