Class1.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. using Microsoft.Extensions.Configuration;
  2. using System.Collections.Generic;
  3. using XYY.Common.Standard;
  4. namespace XYY.Service.Strandard.EMailService
  5. {
  6. public interface IEmailService
  7. {
  8. void Send(List<string> receivers, string subject, string body, bool isHtml, List<string>? bc);
  9. }
  10. public class EmailService : IEmailService
  11. {
  12. private readonly string smptHost;
  13. private readonly string sender;
  14. private readonly string senderName;
  15. private readonly string password;
  16. private readonly int port;
  17. public EmailService(IConfiguration configuration)
  18. {
  19. smptHost = configuration["Email:smtp"];
  20. sender = configuration["Email:sender"];
  21. password = configuration["Email:password"];
  22. senderName = configuration["Email:senderName"];
  23. port = int.Parse(configuration["Email:port"]);
  24. }
  25. public void Send(List<string> receivers, string subject, string body, bool isHtml, List<string>? bc)
  26. {
  27. EmailHelper.SendEmail(senderName, sender, smptHost, port, password, receivers, bc, subject, body, isHtml);
  28. }
  29. }
  30. }