优化邮件服务
This commit is contained in:
@@ -74,7 +74,8 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
{
|
{
|
||||||
return ToResponse(ApiResult.Error($"请配置邮箱信息"));
|
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);
|
string[] toUsers = sendEmailVo.ToUser.Split(",", StringSplitOptions.RemoveEmptyEntries);
|
||||||
if (sendEmailVo.SendMe)
|
if (sendEmailVo.SendMe)
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ namespace ZR.Admin.WebApi
|
|||||||
//ע<><D7A2>REDIS <20><><EFBFBD><EFBFBD>
|
//ע<><D7A2>REDIS <20><><EFBFBD><EFBFBD>
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
RedisServer.Initalize();
|
//RedisServer.Initalize();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,13 +47,14 @@
|
|||||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||||
"MailOptions": {
|
"MailOptions": {
|
||||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
"From": "xxxx@qq.com",
|
"From": "", //eg<65><67>xxxx@qq.com
|
||||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
"Password": "123456",
|
"Password": "123456",
|
||||||
//Э<><D0AD>
|
//Э<><D0AD>
|
||||||
"Smtp": "smtp.qq.com",
|
"Smtp": "smtp.qq.com",
|
||||||
"Port": 587
|
"Port": 587
|
||||||
},
|
},
|
||||||
|
//redis<69><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
"RedisServer": {
|
"RedisServer": {
|
||||||
"Cache": "127.0.0.1:6379,defaultDatabase=0,poolsize=50,ssl=false,writeBuffer=10240,prefix=cache:",
|
"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:"
|
"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;
|
||||||
using MimeKit.Text;
|
using MimeKit.Text;
|
||||||
using System;
|
using System;
|
||||||
@@ -30,7 +31,16 @@ namespace ZR.Common
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool UseSsl { get; set; } = false;
|
public bool UseSsl { get; set; } = false;
|
||||||
public string mailSign = @"";
|
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)
|
public MailHelper(string fromEmail, string smtp, int port, string fromPwd)
|
||||||
{
|
{
|
||||||
FromEmail = fromEmail;
|
FromEmail = fromEmail;
|
||||||
@@ -82,7 +92,6 @@ namespace ZR.Common
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 发送邮件
|
/// 发送邮件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="toName"></param>
|
|
||||||
/// <param name="toAddress"></param>
|
/// <param name="toAddress"></param>
|
||||||
/// <param name="subject"></param>
|
/// <param name="subject"></param>
|
||||||
/// <param name="text"></param>
|
/// <param name="text"></param>
|
||||||
|
|||||||
Reference in New Issue
Block a user