Serilog 如何向多个收件人发送电子邮件

问题描述 投票:0回答:1

我正在开发后台工作人员服务,并尝试使用以下配置向“多个收件人”发送电子邮件。但不幸的是,它不起作用。有没有办法向多个收件人发送电子邮件?我搜索了谷歌但找不到方法。 (serilog aspnet core 6.1 和电子邮件接收器 2.4) { "Name": "CustomEmail", "Args": { "ConnectionInfo": { "NetworkCredentials": { "UserName": "[email protected]", "Password": "1234" }, "FromEmail": "[email protected]", "MailServer": "smtp.gmail.com", "EmailSubject": "[{Level}] Multiple Requests", "Port": "465", "IsBodyHtml": false, "EnableSsl": true, "ToEmail": "[email protected]; [email protected]", "RestrictedToMinimumLevel": "Error", "OutputTemplate": "{Timestamp:yyyy-MM-dd HH:mm} [{Level}] {Message}{NewLine}{Exception}" } } }

以下两种用法均无效。没有错误,也没有电子邮件。顺便说一句,向
仅向一个收件人发送电子邮件

有效。 "ToEmail": "[email protected]; [email protected]" "ToEmail": "[email protected];[email protected]" "ToEmail": "[email protected], [email protected]" "ToEmail": "[email protected],[email protected]"


serilog serilog-aspnetcore
1个回答
0
投票

Serilog 电子邮件接收器

"Serilog": { "Using": [ "Serilog.Sinks.Email", "PurchaseRazerCodesMultipleRequestService", "Serilog.Sinks.File", "Serilog.Sinks.Console", "Serilog.Sinks.MSSqlServer" ], "Override": { "Microsoft.AspNetCore": "Warning" }, { "Name": "CustomEmail", "Args": { "ConnectionInfo": { "NetworkCredentials": { "UserName": "[email protected]", "Password": "123456" }, "FromEmail": "[email protected]", "MailServer": "smtp.gmail.com", "EmailSubject": "[{Level}] Test Requests", "Port": "465", "IsBodyHtml": false, "EnableSsl": true, "ToEmail": "[email protected], [email protected]", "RestrictedToMinimumLevel": "Error", "OutputTemplate": "{Timestamp:yyyy-MM-dd HH:mm} [{Level}] {Message}{NewLine}{Exception}" } } } public static class SerilogCustomEmailExtension { const string DefaultOutputTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}"; public static LoggerConfiguration CustomEmail( this LoggerSinkConfiguration loggerConfiguration, CustomEmailConnectionInfo connectionInfo, string outputTemplate = DefaultOutputTemplate, LogEventLevel restrictedToMinimumLevel = LogEventLevel.Error ) { return loggerConfiguration.Email( connectionInfo, outputTemplate, restrictedToMinimumLevel ); } public class CustomEmailConnectionInfo : EmailConnectionInfo { public CustomEmailConnectionInfo() { NetworkCredentials = new NetworkCredential(); } } }

© www.soinside.com 2019 - 2024. All rights reserved.