示例#1
0
        private SmtpClient GetSmtpClient(SmtpSetting setting = null)
        {
            SmtpClient client = setting == null?_smtpProvider.GetSmtpClient() : _smtpProvider.GetSmtpClient(setting);

            if (client == null)
            {//If SMTP server is not ready save email to temp
                string tempEmlPath = Path.Combine(Directory.GetCurrentDirectory(), "Temp", "emails");
                Directory.CreateDirectory(tempEmlPath);
                client = new SmtpClient
                {
                    DeliveryMethod          = SmtpDeliveryMethod.SpecifiedPickupDirectory,
                    PickupDirectoryLocation = tempEmlPath
                };
                _logger.LogError("SMTP Server is not ready, the email have temporary saved to {0}. for more information: {1}",
                                 tempEmlPath, "http://www.zkea.net/zkeacms/document/smtp-setting");
            }

            return(client);
        }
示例#2
0
 public EmailContext(EmailMessage emailMessage, SmtpSetting smtpSetting)
 {
     EmailMessage = emailMessage;
     SmtpSetting  = smtpSetting;
     RetryCount   = 0;
 }