Exemplo n.º 1
0
        public void TestInvalidMessageValidMailServer()
        {
            IEmailClient smtpServer = new SmtpEmailClient(ValidMailServer);
            var          message    = new MailMessage {
                Body = "body", Subject = "subject"
            };

            message.To.Add("*****@*****.**");
            smtpServer.Send(message);
        }
Exemplo n.º 2
0
        public void TestValidMessageInvalidMailServer()
        {
            IEmailClient smtpServer = new SmtpEmailClient(InvalidMailServer);
            var          message    = new MailMessage
            {
                Body    = "body",
                Subject = "subject",
                From    = new MailAddress("*****@*****.**")
            };

            message.To.Add(new MailAddress("*****@*****.**"));
            smtpServer.Send(message);
        }
Exemplo n.º 3
0
        public static void ClassInitialize(TestContext context)
        {
            if (RuntimeEnvironment.Environment == ApplicationEnvironment.Dev)
            {
                Assert.Inconclusive("Must be run manually in UAT.");
            }

            Container.Push();
            var smtpHost   = Resolve <string>("linkme.communications.smtp.server");
            var smtpServer = new SmtpEmailClient(smtpHost);

            Container.Current.RegisterInstance <IEmailClient>(smtpServer);

            _emailsCommand = Resolve <IEmailsCommand>();
            _memberUser    = Resolve <IMembersQuery>().GetMember(MemberId);
            _employerUser  = Resolve <IEmployersQuery>().GetEmployer(EmployerId);
        }
Exemplo n.º 4
0
        /*
         * IMPORTANT NOTICE
         * 1) The console application will create a self-hosting application hence we need to
         * move the DLL into bin folder
         * Please create bin folder and copy the DLL + exe file there
         *
         * 2) Go to properties of View file and set Copy to output = Copy Always / Copy if newer
         *
         * 3) Model need to be serialized, simply put the attribute [Serializable] on each model
         *
         */

        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("This application is to test sending mail from console (or background process) where there is no web request");

                // Setup smtp client

                var smtpEmailClient = new SmtpEmailClient
                {
                    SmtpClient = new SmtpClient
                    {
                        Host                  = SmtpServer,
                        Port                  = SmtpPort,
                        EnableSsl             = true,
                        UseDefaultCredentials = false,
                        DeliveryMethod        = SmtpDeliveryMethod.Network,
                        Credentials           = new NetworkCredential(
                            FromEmailAddress,
                            FromEmailPassword),
                        Timeout = 20000
                    }
                };

                MailClient.Default = new MailClient(
                    smtpEmailClient,
                    FromEmailAddress,
                    FromEmailName
                    );

                // setup self-host
                SelfHost.Config(AppDomain.CurrentDomain.BaseDirectory);

                Console.WriteLine("1) Model");

                TestModel();

                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Exception found: {ex.Message}\n\n{ex.StackTrace}");
                Console.ReadLine();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        public static void Init()
        {
            var smtpEmailClient = new SmtpEmailClient
            {
                SmtpClient = new SmtpClient
                {
                    Host                  = SmtpServer,
                    Port                  = SmtpPort,
                    EnableSsl             = true,
                    UseDefaultCredentials = false,
                    DeliveryMethod        = SmtpDeliveryMethod.Network,
                    Credentials           = new NetworkCredential(
                        FromEmailAddress,
                        FromEmailPassword),
                    Timeout = 20000
                }
            };

            MailClient.Default = new MailClient(
                smtpEmailClient,
                FromEmailAddress,
                FromEmailName
                );
        }