Example #1
0
        static void Main(string[] args)
        {
            //普通测试
            SmtpMailClient client = new SmtpMailClient("smtp.163.com", 25, true, "XXX", "XXX");

            client.Timeout = 18000;
            MailMessage msg = new MailMessage();

            msg.From = new MailAccount("*****@*****.**", "janky");
            msg.AddTo(new MailAccount("*****@*****.**", "测试1"));
            msg.AddTo(new MailAccount("*****@*****.**"));
            msg.AddCC(new MailAccount("*****@*****.**"));
            //msg.AddCC(new MailAccount("*****@*****.**"));
            msg.MailContent = "<p>IHU 发信IP因发送垃圾邮件或存在异常的连接行为,被暂时挂起。请检测发信IP在历史上的发信情况和发信程序是否存在异常;</p><a href='http://163.com'>163 邮箱</a>";
            msg.Subject     = "测试";
            msg.IsHtml      = true;
            client.Send(msg);

            //附件测试
            client         = new SmtpMailClient("smtp.163.com", 25, true, "XXX", "XXX");
            client.Timeout = 18000;
            msg            = new MailMessage();
            msg.From       = new MailAccount("*****@*****.**", "janky");
            msg.AddTo(new MailAccount("*****@*****.**", "测试1"));
            msg.AddTo(new MailAccount("*****@*****.**"));
            msg.AddCC(new MailAccount("*****@*****.**"));
            msg.MailContent = "<img src='cid:test1234' /><p>IHU 发信IP因发送垃圾邮件或存在异常的连接行为,被暂时挂起。请检测发信IP在历史上的发信情况和发信程序是否存在异常;</p><a href='http://163.com'>163 邮箱</a>";
            msg.Subject     = "测试";
            msg.IsHtml      = true;

            msg.AddAttachment(@"c:\test\test.txt");
            msg.AddAttachment(@"c:\test\taiwan.jpg", "test1234"); //这里是content-id
            msg.AddAttachment(@"c:\test\filechktool.rar");
            client.SendAsync(msg);

            //ssl 测试
            SmtpServerInfo info = new SmtpServerInfo("smtp.gmail.com", 465, true, "XXX", "janky,.XXX");

            info.EnableSsl = true;
            client         = new SmtpMailClient(info);
            client.Timeout = 18000;
            msg            = new MailMessage();
            msg.From       = new MailAccount("*****@*****.**", "系统");
            msg.AddTo(new MailAccount("*****@*****.**", "测试1"));
            msg.AddTo(new MailAccount("*****@*****.**"));
            msg.AddCC(new MailAccount("*****@*****.**"));
            msg.MailContent = "<p>IHU 发信IP因发送垃圾邮件或存在异常的连接行为,被暂时挂起。请检测发信IP在历史上的发信情况和发信程序是否存在异常;</p><a href='http://163.com'>163 邮箱</a>";
            msg.Subject     = "测试";
            msg.IsHtml      = true;
            client.Send(msg);
            Console.ReadKey();
        }
Example #2
0
        public MailViewModel(IMailService mailer)
        {
            this.Send = new Command(() => {
                var mail = new MailMessage {
                    Subject = this.Subject,
                    Message = this.Message
                };
                this.To
                .Split(';')
                .Select(x => x.Trim())
                .ToList()
                .ForEach(x => mail.AddTo(x));

                mailer.Send(mail);
            });
        }
Example #3
0
        public void Test()
        {
            var to = "*****@*****.**";

            to = "*****@*****.**";


            var build = new StringBuilder();

            for (int i = 0; build.Length < 512; i++)
            {
                build.AppendLine(Guid.NewGuid().ToString("N").PadRight(64, '0'));
                build.AppendLine(DateTime.UtcNow.Ticks.ToString("x"));
            }

            var message = new MailMessage();

            message.AddTo(to);
            message.Subject = Guid.NewGuid().ToString("N");
            message.Body    = build.ToString();


            //message.IsBodyHtml = true;
            message.From = new MailAddress("*****@*****.**");

            //message.Save("c:\\1.log");

            var smtpClient = new SmtpClient("mx1.qq.com", 25);

            smtpClient          = new SmtpClient("isnotspam.com", 25);
            smtpClient.SelfHost = "beta.englory.net";

            smtpClient.Send(message);

            Console.WriteLine("completed");
        }