Example #1
0
        private void SendConfirmation(OpenPop.Mime.Header.RfcMailAddress fromAddress, ConfirmationModel model)
        {
            logger.ComposingConfirmationMessage();

            var message = new System.Net.Mail.MailMessage();

            message.From = new MailAddress(configuration.Smtp.From, configuration.Confirmation.Sender);
            message.To.Add(new MailAddress(fromAddress.Address, fromAddress.DisplayName));
            message.Subject    = Smart.Format(configuration.Confirmation.Title, model);
            message.IsBodyHtml = true;
            message.Body       = Smart.Format(configuration.Confirmation.Body, model);

            var smtp = new SmtpClient(configuration.Smtp.Hostname, configuration.Smtp.Port);

            smtp.EnableSsl   = configuration.Smtp.UseSsl;
            smtp.Credentials = new System.Net.NetworkCredential(configuration.Smtp.Username, configuration.Smtp.Password);

            try
            {
                logger.SendingConfirmationMessageTo(fromAddress.Address);
                smtp.Send(message);
                logger.ConfirmationMessageSentTo(fromAddress.Address);
            }
            catch (Exception e)
            {
                logger.FailToSendConfirmationMessage(message, e);
            }//try
        }