コード例 #1
0
        public SendGridMailSender(string username, string password, IMailInterceptor interceptor)
        {
            _interceptor = interceptor;
            var credentials = new NetworkCredential(username, password);

            _client = new Web(credentials);
        }
コード例 #2
0
        /// <summary>
        ///     Creates a new EmailResult.  You must call ExecuteCore() before this result
        ///     can be successfully delivered.
        /// </summary>
        /// <param name="interceptor">The IMailInterceptor that we will call when delivering MailAttributes.</param>
        /// <param name="sender">The IMailSender that we will use to send MailAttributes.</param>
        /// <param name="mailAttributes">The MailAttributes messageBase who's body needs populating.</param>
        /// <param name="viewName">The view to use when rendering the messageBase body (can be null)</param>
        /// <param name="masterName">The maste rpage to use when rendering the messageBase body (can be null)</param>
        /// <param name="messageEncoding">The encoding to use when rendering a messageBase.</param>
        /// <param name="trimBody">Whether or not we should trim whitespace from the beginning and end of the messageBase body.</param>
        public EmailResult(IMailInterceptor interceptor, IMailSender sender, MailAttributes mailAttributes, string viewName,
                           string masterName, Encoding messageEncoding, bool trimBody)
        {
            if (interceptor == null)
            {
                throw new ArgumentNullException("interceptor");
            }

            if (sender == null)
            {
                throw new ArgumentNullException("sender");
            }

            if (mailAttributes == null)
            {
                throw new ArgumentNullException("mailAttributes");
            }

            ViewName         = viewName ?? ViewName;
            MasterName       = masterName ?? MasterName;
            _messageEncoding = messageEncoding;
            _mailAttributes  = mailAttributes;
            _sender          = sender;
            _interceptor     = interceptor;
            _trimBody        = trimBody;
        }
コード例 #3
0
        public MandrillMailSender(string apiKey, IMailInterceptor interceptor)
        {
            if (string.IsNullOrWhiteSpace(apiKey))
                throw new ArgumentNullException("apiKey",
                    "The AppSetting 'MandrillApiKey' is not defined. Either define this configuration section or use the constructor with apiKey parameter.");

            _interceptor = interceptor;
            _client = new MandrillApi(apiKey);
        }
コード例 #4
0
        public SendGridMailSender(string username, string password, IMailInterceptor interceptor = null)
        {
            if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password))
                throw new InvalidOperationException(
                    "The AppSetting 'SendGridUser' and 'SendGridPass' are not defined correctly. Either define this configuration section or use the constructor with username and password parameter.");

            _interceptor = interceptor;
            var credentials = new NetworkCredential(username, password);
            _client = new Web(credentials);
        }
コード例 #5
0
        /// <summary>
        ///     Creates a new delivery helper to be used for sending messages.
        /// </summary>
        /// <param name="sender">The sender to use when delivering mail.</param>
        /// <param name="interceptor">The interceptor to report with while delivering mail.</param>
        public DeliveryHelper(IMailSender sender, IMailInterceptor interceptor)
        {
            if (interceptor == null)
                throw new ArgumentNullException("interceptor");

            if (sender == null)
                throw new ArgumentNullException("sender");

            _sender = sender;
            _interceptor = interceptor;
        }
コード例 #6
0
        public MandrillMailSender(string apiKey, IMailInterceptor interceptor)
        {
            if (string.IsNullOrWhiteSpace(apiKey))
            {
                throw new ArgumentNullException("apiKey",
                                                "The AppSetting 'MandrillApiKey' is not defined. Either define this configuration section or use the constructor with apiKey parameter.");
            }

            _interceptor = interceptor;
            _client      = new MandrillApi(apiKey);
        }
コード例 #7
0
ファイル: EmailResult.cs プロジェクト: artbear/social
        /// <summary>
        /// Creates a new EmailResult.  You must call ExecuteCore() before this result
        /// can be successfully delivered.
        /// </summary>
        /// <param name="interceptor">The IMailInterceptor that we will call when delivering mail.</param>
        /// <param name="sender">The IMailSender that we will use to send mail.</param>
        /// <param name="mail">The mail message who's body needs populating.</param>
        /// <param name="viewName">The view to use when rendering the message body (can be null)</param>
        /// <param name="masterName">The maste rpage to use when rendering the message body (can be null)</param>
        /// <param name="messageEncoding">The encoding to use when rendering a message.</param>
        /// <param name="trimBody">Whether or not we should trim whitespace from the beginning and end of the message body.</param>
        public EmailResult(IMailInterceptor interceptor, IMailSender sender, MailMessage mail, string viewName, string masterName, Encoding messageEncoding, bool trimBody)
        {
            if (interceptor == null)
                throw new ArgumentNullException("interceptor");

            if (sender == null)
                throw new ArgumentNullException("sender");

            if (mail == null)
                throw new ArgumentNullException("mail");

            ViewName = viewName ?? ViewName;
            MasterName = masterName ?? MasterName;
            MessageEncoding = messageEncoding;
            Mail = mail;
            MailSender = sender;
            _interceptor = interceptor;
            _deliveryHelper = new DeliveryHelper(sender, interceptor);
            _trimBody = trimBody;
        }
コード例 #8
0
        /// <summary>
        ///     Creates a new EmailResult.  You must call ExecuteCore() before this result
        ///     can be successfully delivered.
        /// </summary>
        /// <param name="interceptor">The IMailInterceptor that we will call when delivering MailAttributes.</param>
        /// <param name="sender">The IMailSender that we will use to send MailAttributes.</param>
        /// <param name="mailAttributes">The MailAttributes messageBase who's body needs populating.</param>
        /// <param name="viewName">The view to use when rendering the messageBase body (can be null)</param>
        /// <param name="masterName">The maste rpage to use when rendering the messageBase body (can be null)</param>
        /// <param name="messageEncoding">The encoding to use when rendering a messageBase.</param>
        /// <param name="trimBody">Whether or not we should trim whitespace from the beginning and end of the messageBase body.</param>
        public EmailResult(IMailInterceptor interceptor, IMailSender sender, MailAttributes mailAttributes, string viewName,
            string masterName, Encoding messageEncoding, bool trimBody)
        {
            if (interceptor == null)
                throw new ArgumentNullException("interceptor");

            if (sender == null)
                throw new ArgumentNullException("sender");

            if (mailAttributes == null)
                throw new ArgumentNullException("mailAttributes");

            ViewName = viewName ?? ViewName;
            MasterName = masterName ?? MasterName;
            _messageEncoding = messageEncoding;
            _mailAttributes = mailAttributes;
            _sender = sender;
            _interceptor = interceptor;
            _trimBody = trimBody;
        }
コード例 #9
0
 public SendGridMailSender(string username, string password, IMailInterceptor interceptor)
 {
     _interceptor = interceptor;
     var credentials = new NetworkCredential(username, password);
     _client = new Web(credentials);
 }
コード例 #10
0
 /// <summary>
 ///     Creates a new SMTPMailMessage sender based on System.Net.MailAttributes.SmtpClient
 /// </summary>
 /// <param name="client">The underlying SmtpClient instance to use.</param>
 public SmtpMailSender(SmtpClient client, IMailInterceptor interceptor)
 {
     _interceptor = interceptor;
     _client      = client;
 }
コード例 #11
0
 /// <summary>
 ///     Creates a new SMTPMailMessage sender based on System.Net.MailAttributes.SmtpClient
 /// </summary>
 /// <param name="client">The underlying SmtpClient instance to use.</param>
 public SmtpMailSender(SmtpClient client, IMailInterceptor interceptor)
 {
     _interceptor = interceptor;
     _client = client;
 }
コード例 #12
0
 /// <summary>
 ///     Creates a new SMTPMailMessage sender based on System.Net.MailAttributes.SmtpClient
 /// </summary>
 public SmtpMailSender(IMailInterceptor interceptor = null)
     : this(new SmtpClient(), interceptor)
 {
 }
コード例 #13
0
 public MandrillMailSender(IMailInterceptor interceptor = null) : this(ConfigurationManager.AppSettings["MandrillApiKey"], interceptor) { }
コード例 #14
0
 public SendGridMailSender(IMailInterceptor interceptor = null) : this(ConfigurationManager.AppSettings["SendGridUser"], ConfigurationManager.AppSettings["SendGridPass"], interceptor) { }