Beispiel #1
0
        /// <summary>
        /// Get an email connection
        /// </summary>
        /// <returns>An email connection</returns>
        private static ImapClient GetClient()
        {
            string host     = EmailConfig.GetHost();
            string username = EmailConfig.GetUserName();
            string password = EmailConfig.GetPassword();

            return(ClientFactory.GetEmailClient(host, username, password, 993, 10000, true, true));
        }
        public void BasicConnectionTest()
        {
            string host     = EmailConfig.GetHost();
            string username = EmailConfig.GetUserName();
            string password = EmailConfig.GetPassword();
            int    port     = EmailConfig.GetPort();

            using (EmailDriver test = new EmailDriver(host, username, password, port, 10000, true, true))
            {
                test.EmailConnection.NoOp();
            }
        }
Beispiel #3
0
        public static void Cleanup()
        {
            string host     = EmailConfig.GetHost();
            string username = EmailConfig.GetUserName();
            string password = EmailConfig.GetPassword();
            int    port     = EmailConfig.GetPort();
            bool   isSsl    = EmailConfig.GetEmailViaSSL();
            bool   checkSsl = EmailConfig.GetEmailSkipSslValidation();

            using (EmailDriver driver = new EmailDriver(host, username, password, port, 10000, isSsl, checkSsl))
            {
                driver.SelectMailbox("Inbox");
                foreach (MimeMessage messageHeader in driver.GetAllMessageHeaders())
                {
                    driver.DeleteMessage(messageHeader);
                    Thread.Sleep(100);
                }
            }
        }
        public void GetPasswordTest()
        {
            // Replace the password so it doesn't need to be hard-coded in our test
            string savePass = EmailConfig.GetPassword();
            string tempPass = "******";

            Config.AddTestSettingValues(new Dictionary <string, string> {
                { "EmailPassword", tempPass }
            }, "EmailMaqs", true);

            try
            {
                string password = EmailConfig.GetPassword();
                Assert.AreEqual(password, tempPass);
            }
            finally
            {
                Config.AddTestSettingValues(new Dictionary <string, string> {
                    { "EmailPassword", savePass }
                }, "EmailMaqs", true);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Send a test email
        /// </summary>
        /// <param name="subject">Subject of the test email</param>
        private void SendTestEmail(string subject)
        {
            SystemEmail.SmtpClient client = new SystemEmail.SmtpClient
            {
                Port                  = 25,
                Host                  = "localhost",
                EnableSsl             = false,
                Timeout               = 60000,
                DeliveryMethod        = SystemEmail.SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials           = new System.Net.NetworkCredential(EmailConfig.GetUserName(), EmailConfig.GetPassword())
            };

            SystemEmail.MailMessage message = new SystemEmail.MailMessage(EmailConfig.GetUserName(), EmailConfig.GetUserName(), subject, "test")
            {
                BodyEncoding = UTF8Encoding.UTF8
            };
            message.Headers.Add("Message-Id", Guid.NewGuid().ToString());
            message.DeliveryNotificationOptions = SystemEmail.DeliveryNotificationOptions.OnFailure;

            client.Send(message);

            Thread.Sleep(5000);
        }
Beispiel #6
0
        /// <summary>
        /// Send a test email
        /// </summary>
        /// <param name="subject">Subject of the test email</param>
        private void SendTestEmail(string subject)
        {
            SystemEmail.SmtpClient client = new SystemEmail.SmtpClient();
            client.Port                  = 587;
            client.Host                  = "smtp.gmail.com";
            client.EnableSsl             = true;
            client.Timeout               = 60000;
            client.DeliveryMethod        = SystemEmail.SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;
            client.Credentials           = new System.Net.NetworkCredential(EmailConfig.GetUserName(), EmailConfig.GetPassword());

            SystemEmail.MailMessage message = new SystemEmail.MailMessage(EmailConfig.GetUserName(), EmailConfig.GetUserName(), subject, "test");
            message.BodyEncoding = UTF8Encoding.UTF8;
            message.DeliveryNotificationOptions = SystemEmail.DeliveryNotificationOptions.OnFailure;

            client.Send(message);

            Thread.Sleep(5000);
        }