1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-05 21:18:13 -05:00

add message id header to smtp mail

This commit is contained in:
Kyle Spearrin 2018-09-10 08:45:57 -04:00
parent fb45f75bc8
commit 0fda72c6b0

View File

@ -11,6 +11,7 @@ namespace Bit.Core.Services
{
private readonly GlobalSettings _globalSettings;
private readonly ILogger<SmtpMailDeliveryService> _logger;
private readonly string _replyDomain;
public SmtpMailDeliveryService(
GlobalSettings globalSettings,
@ -20,6 +21,10 @@ namespace Bit.Core.Services
{
throw new ArgumentNullException(nameof(globalSettings.Mail.Smtp.Host));
}
if(globalSettings.Mail?.ReplyToEmail?.Contains("@") ?? false)
{
_replyDomain = globalSettings.Mail.ReplyToEmail.Split('@')[1];
}
_globalSettings = globalSettings;
_logger = logger;
@ -57,6 +62,10 @@ namespace Bit.Core.Services
smtpMessage.SubjectEncoding = Encoding.UTF8;
smtpMessage.BodyEncoding = Encoding.UTF8;
smtpMessage.BodyTransferEncoding = System.Net.Mime.TransferEncoding.QuotedPrintable;
if(!string.IsNullOrWhiteSpace(_replyDomain))
{
smtpMessage.Headers.Add("Message-ID", $"<{Guid.NewGuid()}@{_replyDomain}>");
}
foreach(var address in message.ToEmails)
{
smtpMessage.To.Add(new MailAddress(address));