feat:邮件发送新增签名配置
This commit is contained in:
parent
13f8ec1cec
commit
78aa48a975
@ -24,6 +24,7 @@ namespace Infrastructure
|
|||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
public string Smtp { get; set; }
|
public string Smtp { get; set; }
|
||||||
public int Port { get; set; }
|
public int Port { get; set; }
|
||||||
|
public string Signature { get; set; }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 上传
|
/// 上传
|
||||||
|
|||||||
@ -47,7 +47,8 @@
|
|||||||
"Password": "123456",
|
"Password": "123456",
|
||||||
//协议
|
//协议
|
||||||
"Smtp": "smtp.qq.com",
|
"Smtp": "smtp.qq.com",
|
||||||
"Port": 587
|
"Port": 587,
|
||||||
|
"Signature": "系统邮件,请勿回复!"
|
||||||
},
|
},
|
||||||
//redis服务配置
|
//redis服务配置
|
||||||
"RedisServer": {
|
"RedisServer": {
|
||||||
|
|||||||
@ -27,10 +27,13 @@ namespace ZR.Common
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int Port { get; set; } = 587;
|
public int Port { get; set; } = 587;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 邮件签名
|
||||||
|
/// </summary>
|
||||||
|
public string Signature { get; set; }
|
||||||
|
/// <summary>
|
||||||
/// 是否使用SSL协议
|
/// 是否使用SSL协议
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool UseSsl { get; set; } = false;
|
public bool UseSsl { get; set; } = false;
|
||||||
public string mailSign = @"邮件来自C# 程序发送";
|
|
||||||
private readonly MailOptions mailOptions = new();
|
private readonly MailOptions mailOptions = new();
|
||||||
|
|
||||||
public MailHelper()
|
public MailHelper()
|
||||||
@ -56,7 +59,7 @@ namespace ZR.Common
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 发送一个人
|
/// 发送一个
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="toAddress"></param>
|
/// <param name="toAddress"></param>
|
||||||
/// <param name="subject"></param>
|
/// <param name="subject"></param>
|
||||||
@ -105,7 +108,7 @@ namespace ZR.Common
|
|||||||
//收件人
|
//收件人
|
||||||
message.To.AddRange(toAddress);
|
message.To.AddRange(toAddress);
|
||||||
message.Subject = subject;
|
message.Subject = subject;
|
||||||
//message.Date = DateTime.Now;
|
message.Date = DateTime.Now;
|
||||||
|
|
||||||
//创建附件Multipart
|
//创建附件Multipart
|
||||||
Multipart multipart = new Multipart("mixed");
|
Multipart multipart = new Multipart("mixed");
|
||||||
@ -120,14 +123,14 @@ namespace ZR.Common
|
|||||||
alternative.Add(Html);
|
alternative.Add(Html);
|
||||||
}
|
}
|
||||||
//文本内容
|
//文本内容
|
||||||
if (!string.IsNullOrEmpty(text))
|
//if (!string.IsNullOrEmpty(text))
|
||||||
|
//{
|
||||||
|
var plain = new TextPart(TextFormat.Plain)
|
||||||
{
|
{
|
||||||
var plain = new TextPart(TextFormat.Plain)
|
Text = text + "\r\n\n\n" + mailOptions.Signature
|
||||||
{
|
};
|
||||||
Text = text + "\r\n\n\n" + mailSign
|
alternative.Add(plain);
|
||||||
};
|
//}
|
||||||
alternative.Add(plain);
|
|
||||||
}
|
|
||||||
|
|
||||||
//附件
|
//附件
|
||||||
if (!string.IsNullOrEmpty(path))
|
if (!string.IsNullOrEmpty(path))
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.13.0" />
|
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.13.0" />
|
||||||
<PackageReference Include="CSRedisCore" Version="3.8.2" />
|
<PackageReference Include="CSRedisCore" Version="3.8.2" />
|
||||||
<PackageReference Include="EPPlus" Version="6.0.4" />
|
<PackageReference Include="EPPlus" Version="6.0.4" />
|
||||||
<PackageReference Include="MailKit" Version="3.2.0" />
|
<PackageReference Include="MailKit" Version="3.3.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user