优化邮件服务
This commit is contained in:
parent
da14901f3e
commit
cf27c7115c
@ -74,7 +74,8 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
{
|
||||
return ToResponse(ApiResult.Error($"请配置邮箱信息"));
|
||||
}
|
||||
MailHelper mailHelper = new(OptionsSetting.MailOptions.From, OptionsSetting.MailOptions.Smtp, OptionsSetting.MailOptions.Port, OptionsSetting.MailOptions.Password);
|
||||
|
||||
MailHelper mailHelper = new();
|
||||
|
||||
string[] toUsers = sendEmailVo.ToUser.Split(",", StringSplitOptions.RemoveEmptyEntries);
|
||||
if (sendEmailVo.SendMe)
|
||||
|
||||
@ -143,7 +143,7 @@ namespace ZR.Admin.WebApi
|
||||
//×¢²áREDIS ·şÎñ
|
||||
Task.Run(() =>
|
||||
{
|
||||
RedisServer.Initalize();
|
||||
//RedisServer.Initalize();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,13 +47,14 @@
|
||||
//邮箱配置信息
|
||||
"MailOptions": {
|
||||
//发送人邮箱
|
||||
"From": "xxxx@qq.com",
|
||||
"From": "", //eg:xxxx@qq.com
|
||||
//发送人邮箱密码
|
||||
"Password": "123456",
|
||||
//协议
|
||||
"Smtp": "smtp.qq.com",
|
||||
"Port": 587
|
||||
},
|
||||
//redis服务配置
|
||||
"RedisServer": {
|
||||
"Cache": "127.0.0.1:6379,defaultDatabase=0,poolsize=50,ssl=false,writeBuffer=10240,prefix=cache:",
|
||||
"Session": "127.0.0.1:6379,defaultDatabase=0,poolsize=50,ssl=false,writeBuffer=10240,prefix=session:"
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using MailKit.Net.Smtp;
|
||||
using Infrastructure;
|
||||
using MailKit.Net.Smtp;
|
||||
using MimeKit;
|
||||
using MimeKit.Text;
|
||||
using System;
|
||||
@ -30,7 +31,16 @@ namespace ZR.Common
|
||||
/// </summary>
|
||||
public bool UseSsl { get; set; } = false;
|
||||
public string mailSign = @"";
|
||||
private readonly MailOptions mailOptions = new();
|
||||
|
||||
public MailHelper()
|
||||
{
|
||||
ConfigUtils.Instance.Bind("MailOptions", mailOptions);
|
||||
FromEmail = mailOptions.From;
|
||||
Smtp = mailOptions.Smtp;
|
||||
FromPwd = mailOptions.Password;
|
||||
Port = mailOptions.Port;
|
||||
}
|
||||
public MailHelper(string fromEmail, string smtp, int port, string fromPwd)
|
||||
{
|
||||
FromEmail = fromEmail;
|
||||
@ -82,7 +92,6 @@ namespace ZR.Common
|
||||
/// <summary>
|
||||
/// 发送邮件
|
||||
/// </summary>
|
||||
/// <param name="toName"></param>
|
||||
/// <param name="toAddress"></param>
|
||||
/// <param name="subject"></param>
|
||||
/// <param name="text"></param>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user