Yuebon.NetCore/Yuebon.Email.Core/SendMailHelper.cs
(开头部分) 9KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using MailKit;
using MailKit.Net.Smtp;
using MailKit.Security;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using Yuebon.Commons.Cache;
using Yuebon.Commons.Encrypt;
using Yuebon.Commons.Extensions;
using Yuebon.Commons.Json;
using Yuebon.Commons.Options;
namespace Yuebon.Email
{
/// <summary>
/// 发送邮件
/// </summary>
public static class SendMailHelper
{
/// <summary>
/// 发送邮件
/// </summary>
/// <param name="mailBodyEntity">邮件基础信息</param>
public static async Task<SendResultEntity> SendMail(MailBodyEntity mailBodyEntity)
{
var sendResultEntity = new SendResultEntity();
if (mailBodyEntity == null)
{
throw new ArgumentNullException();
}
SendServerConfigurationEntity sendServerConfiguration = new SendServerConfigurationEntity();
YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
AppSetting sysSetting = yuebonCacheHelper.Get<AppSetting>("SysSetting");
if (sysSetting != null)
{
sendServerConfiguration.SmtpHost = DEncrypt.Decrypt(sysSetting.Emailsmtp);
sendServerConfiguration.SenderAccount = sysSetting.Emailusername;
sendServerConfiguration.SenderPassword = DEncrypt.Decrypt(sysSetting.Emailpassword);
sendServerConfiguration.SmtpPort = sysSetting.Emailport.ToInt();
sendServerConfiguration.IsSsl =sysSetting.Emailssl.ToBool();
sendServerConfiguration.MailEncoding ="utf-8";
mailBodyEntity.Sender = sysSetting.Emailnickname;
mailBodyEntity.SenderAddress = sysSetting.Emailusername;
}
else
{
sendResultEntity.ResultInformation ="邮件服务器未配置";
sendResultEntity.ResultStatus = false;
throw new ArgumentNullException();
}
sendResultEntity= await SendMail(mailBodyEntity, sendServerConfiguration);
return sendResultEntity;
}
/// <summary>
/// 发送邮件
/// </summary>
后面还有 182 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。