⚡ 邮件发送优化
This commit is contained in:
@@ -70,15 +70,15 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// <param name="sendEmailVo">请求参数接收实体</param>
|
||||
/// <returns></returns>
|
||||
[ActionPermissionFilter(Permission = "tool:email:send")]
|
||||
[Log(Title = "发送邮件", IsSaveRequestData = false)]
|
||||
[Log(Title = "发送邮件")]
|
||||
[HttpPost]
|
||||
public IActionResult SendEmail([FromBody] SendEmailDto sendEmailVo)
|
||||
{
|
||||
if (sendEmailVo == null || string.IsNullOrEmpty(sendEmailVo.Subject) || string.IsNullOrEmpty(sendEmailVo.ToUser))
|
||||
if (sendEmailVo == null)
|
||||
{
|
||||
return ToResponse(ApiResult.Error($"请求参数不完整"));
|
||||
}
|
||||
if (string.IsNullOrEmpty(OptionsSetting.MailOptions.From) || string.IsNullOrEmpty(OptionsSetting.MailOptions.Password))
|
||||
if (string.IsNullOrEmpty(OptionsSetting.MailOptions.FromEmail) || string.IsNullOrEmpty(OptionsSetting.MailOptions.Password))
|
||||
{
|
||||
return ToResponse(ApiResult.Error($"请配置邮箱信息"));
|
||||
}
|
||||
@@ -90,11 +90,11 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
{
|
||||
toUsers.Append(mailHelper.FromEmail);
|
||||
}
|
||||
mailHelper.SendMail(toUsers, sendEmailVo.Subject, sendEmailVo.Content, sendEmailVo.FileUrl, sendEmailVo.HtmlContent);
|
||||
string result = mailHelper.SendMail(toUsers, sendEmailVo.Subject, sendEmailVo.Content, sendEmailVo.FileUrl, sendEmailVo.HtmlContent);
|
||||
|
||||
logger.Info($"发送邮件{JsonConvert.SerializeObject(sendEmailVo)}");
|
||||
logger.Info($"发送邮件{JsonConvert.SerializeObject(sendEmailVo)}, 结果{result}");
|
||||
|
||||
return SUCCESS(true);
|
||||
return SUCCESS(result);
|
||||
}
|
||||
|
||||
#region 上传
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace ZR.Admin.WebApi.Extensions
|
||||
/// 初始化db
|
||||
/// </summary>
|
||||
/// <param name="Configuration"></param>
|
||||
public static void AddDb(IConfiguration Configuration)
|
||||
public static void AddDb(this IServiceCollection services, IConfiguration Configuration)
|
||||
{
|
||||
List<DbConfigs> dbConfigs = Configuration.GetSection("DbConfigs").Get<List<DbConfigs>>();
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
"urls": "http://localhost:8888", //项目启动url,如果改动端口前端对应devServer也需要进行修改
|
||||
"corsUrls": "http://localhost:8887", //跨域地址(前端启动项目,前后端分离单独部署需要设置),多个用","隔开
|
||||
"JwtSettings": {
|
||||
"Issuer": "ZRAdmin.NET",
|
||||
"Audience": "ZRAdmin.NET",
|
||||
"Issuer": "ZRAdmin.NET", //即token的签发者。
|
||||
"Audience": "ZRAdmin.NET", //指该token是服务于哪个群体的(群体范围)
|
||||
"SecretKey": "SecretKey-ZRADMIN.NET-20210101",
|
||||
"Expire": 1440 //jwt登录过期时间(分)
|
||||
},
|
||||
@@ -60,8 +60,10 @@
|
||||
},
|
||||
//邮箱配置信息
|
||||
"MailOptions": {
|
||||
//发件人名称
|
||||
"FromName": "system",
|
||||
//发送人邮箱
|
||||
"From": "", //eg:xxxx@qq.com
|
||||
"FromEmail": "", //eg:xxxx@qq.com
|
||||
//发送人邮箱密码
|
||||
"Password": "123456",
|
||||
//协议
|
||||
|
||||
Reference in New Issue
Block a user