public override string Execute(EventEntry evtlog) { F2BSection config = F2B.Config.Instance; ProcessorEventStringTemplate tpl = new ProcessorEventStringTemplate(evtlog); string senderEx = tpl.Apply(sender); string recipientEx = Regex.Replace(tpl.Apply(recipient), @"^[ ,]*(.*?)[ ,]*$", "$1"); string subjectEx = tpl.Apply(subject); Log.Info("Sending mail notification (from=" + senderEx + ",to=" + recipientEx + ",subject=" + subjectEx + ")"); MailMessage mail = new MailMessage(senderEx, recipientEx); mail.Subject = subjectEx; mail.Body = tpl.Apply(body); SmtpClient client = new SmtpClient(); client.Port = config.Smtp.Port.Value; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Host = config.Smtp.Host.Value; client.EnableSsl = config.Smtp.Ssl.Value; client.Credentials = smtpAuth; client.Send(mail); #if DEBUG Interlocked.Increment(ref nmsgs); #endif return(goto_next); }
private static AccountElement Config(string name) { F2BSection config = F2B.Config.Instance; foreach (AccountElement accountConfig in config.Accounts) { if (accountConfig.Name != name) { continue; } return(accountConfig); } return(null); }