Beispiel #1
0
        protected async Task SendEmail(Email email)
        {
            var mimeMessage = new MimeMessage();

            mimeMessage.From.Add(new MailboxAddress(settings.SenderName, settings.Sender));
            mimeMessage.To.Add(new MailboxAddress(email.Recipient));
            mimeMessage.Subject = email.Subject;
            mimeMessage.Body    = new TextPart("html")
            {
                Text = email.Body
            };

            using (SmtpClient client = new SmtpClient())
            {
                await client.ConnectAsync(settings.MailServer, settings.MailPort, true);

                await client.AuthenticateAsync(settings.Sender, settings.Password);

                await client.SendAsync(mimeMessage);

                await client.DisconnectAsync(true);
            }
        }
Beispiel #2
0
        private async Task SendEmailAsync(string email, string message)
        {
            var emailmessage = new MimeMessage();

            emailmessage.From.Add(new MailboxAddress("Shortenet Link", HttpContext.User.Identity.Name));
            emailmessage.To.Add(new MailboxAddress("", email));
            emailmessage.Subject = "Open link";
            emailmessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = message
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync("smtp.gmail.com", 465);

                await client.AuthenticateAsync("*****@*****.**", "mpvsqwerty");

                await client.SendAsync(emailmessage);

                await client.DisconnectAsync(true);
            }
        }
        public async Task SendEmailAsync(string email, string subject, string message)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress("FiorelloC", "*****@*****.**"));
            emailMessage.To.Add(new MailboxAddress(string.Empty, email));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = message
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync("smtp.mail.ru", 465, true);

                await client.AuthenticateAsync("*****@*****.**", "IA2UoIuory6_");

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
Beispiel #4
0
        public async Task SendEmailAsync(string email, string subject, string message)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress("Nursoft saytının administrasiyası", "*****@*****.**"));
            emailMessage.To.Add(new MailboxAddress("", email));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = message
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync("mail.hosting.reg.ru", 587, false);

                await client.AuthenticateAsync("*****@*****.**", "nursoft2020");

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
        public async Task SendEmailAsync(string email, string subject, string message)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress("Администрация сайта", "*****@*****.**"));
            emailMessage.To.Add(new MailboxAddress("", email));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = message
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync("smtp.gmail.com", 587, false);

                await client.AuthenticateAsync("*****@*****.**", "Sasha2001kaplenkO");

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
Beispiel #6
0
        public async Task SendEmailAsync(string email, string subject, string message)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress("У Артемки в хатке", "*****@*****.**"));
            emailMessage.To.Add(new MailboxAddress("", email));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = message
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync("smtp.mail.ru", 25, false);

                await client.AuthenticateAsync("*****@*****.**", "1a2r3t4e");

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
Beispiel #7
0
        public async Task SendEmailAsync(string email, string subject, string message)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress("Администрация сайта", _emailConfiguration.SmtpUsername));
            emailMessage.To.Add(new MailboxAddress("", email));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = message
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync(_emailConfiguration.SmtpServer, _emailConfiguration.SmtpPort, false);

                await client.AuthenticateAsync(_emailConfiguration.SmtpUsername, _emailConfiguration.SmtpPassword);

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
        public async Task SendEmailAsync(string email, string subject, string message)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress(ec.FromName, ec.FromAddress));
            emailMessage.To.Add(new MailboxAddress("", email));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = message
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync(ec.MailServerAddress, Convert.ToInt32(ec.MailServerPort), true);

                await client.AuthenticateAsync(ec.UserId, ec.UserPassword);

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
Beispiel #9
0
        public async Task SendEmailAsync(string email, string subject, string htmlMessage)
        {
            MimeMessage emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress("Администрация сайта", "*****@*****.**"));
            emailMessage.To.Add(new MailboxAddress("", email));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = htmlMessage
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync("smtp.gmail.com", 25, false);

                await client.AuthenticateAsync("*****@*****.**", "FilmStorePassword11");

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
Beispiel #10
0
        public async Task SendEmailAsync(string email, string subject, string message)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress("Game Step", "*****@*****.**"));
            emailMessage.To.Add(new MailboxAddress("", email));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = message
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync("smtp.gmail.com", 587, false);

                await client.AuthenticateAsync("*****@*****.**", "bubblesitenews");

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
        public async Task SendEmailAsync(string email, string subject, string message)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress("Task Tracking System", "*****@*****.**"));
            emailMessage.To.Add(new MailboxAddress("", email));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Plain)
            {
                Text = message
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync("smtp.gmail.com", 587, MailKit.Security.SecureSocketOptions.StartTlsWhenAvailable);

                await client.AuthenticateAsync("*****@*****.**", "TestPassword123");

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
Beispiel #12
0
        public async Task SendEmailAsync(Email email, CancellationToken cancellationToken = default)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress("Служба поддержи DevOX", email.SenderEmail));
            emailMessage.To.Add(new MailboxAddress(email.RecipientEmail));
            emailMessage.Subject = email.Subject;
            emailMessage.Body    = new TextPart(TextFormat.Html)
            {
                Text = email.Content
            };
            using (var client = new SmtpClient())
            {
                await client.ConnectAsync(_emailSettings.SmtpServer, _emailSettings.SmtpPort, MailKit.Security.SecureSocketOptions.None, cancellationToken);

                //No need to implement authentication yet
                //client.AuthenticationMechanisms.Remove("XOAUTH2");

                await client.SendAsync(emailMessage, cancellationToken);

                await client.DisconnectAsync(true, cancellationToken);
            }
        }
Beispiel #13
0
        public async Task SendEmailAsync(string email, string subject, string message)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress("Administration", Configuration.GetSection("EmailServices")["EmailAdress"]));
            emailMessage.To.Add(new MailboxAddress("", email));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = message
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync("smtp.mail.ru", 25, false);

                await client.AuthenticateAsync(Configuration.GetSection("EmailServices")["EmailAdress"], Configuration.GetSection("EmailServices")["Password"]);

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
Beispiel #14
0
        public async Task SendEmailAsync(string reciever, string subject, string message)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress("Администрация сайта", "*****@*****.**"));
            emailMessage.To.Add(new MailboxAddress("", reciever));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = message
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync("smtp.gmail.com", 587, false);

                await client.AuthenticateAsync("*****@*****.**", "love18Barcelona");

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
        public async Task SendEmailAsync(string email, string subject, string message)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress("HealthyFoodOnlineShop", "*****@*****.**"));
            emailMessage.To.Add(new MailboxAddress("", email));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = message
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync("smtp.gmail.com", 465, true);

                await client.AuthenticateAsync("*****@*****.**", "asd");

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
Beispiel #16
0
        public async Task SendEmailAsync(string email, string subject, string textMessage)
        {
            var message = new MimeMessage();

            message.From.Add(new MailboxAddress("Seller", "*****@*****.**"));
            message.To.Add(new MailboxAddress("Client", email));
            message.Subject = subject;
            message.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = textMessage
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync("smtp.gmail.com", 465, true);

                await client.AuthenticateAsync(_emailCompany, _passwordCompany);

                await client.SendAsync(message);

                await client.DisconnectAsync(true);
            }
        }
        public async Task SendEmailAsync(string email, string subject, string message)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress("Администрация cервиса", "*****@*****.**"));
            emailMessage.To.Add(new MailboxAddress("", email));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = message
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync("smtp-mail.outlook.com", 587, false);

                await client.AuthenticateAsync("*****@*****.**", "diawestactive95");

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
        public async Task SendEmailAsync(string email, string subject, string message)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress("Администрация сайта", "*****@*****.**"));
            emailMessage.To.Add(new MailboxAddress("", email));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = message
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync("smtp.gmail.com", 465, true);

                await client.AuthenticateAsync("*****@*****.**", "jyutdapqmetlqhvj");

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
Beispiel #19
0
        public async Task SendEmailAsync(string email, string subject, string message)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress("DynastyComics", "*****@*****.**"));
            emailMessage.To.Add(new MailboxAddress("", email));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = message
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync("smtp.mail.ru", 25, false);

                await client.AuthenticateAsync("*****@*****.**", "37vepenO");

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
Beispiel #20
0
        public async Task SendEmailAsync(string email, string subject, string message)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress("Site administration", _config["email"]));
            emailMessage.To.Add(new MailboxAddress("", email));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = message
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync("smtp.mail.ru", 587, false);

                await client.AuthenticateAsync(_config["email"], _config["password"]);

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
Beispiel #21
0
        public async Task Send(EmailMessage emailMessage)
        {
            if (_config.MailServiceActive)
            {
                var message = new MimeMessage();
                message.To.AddRange(emailMessage.To.Select(x => new MailboxAddress(x.Name, x.Address)));
                message.From.AddRange(emailMessage.From.Select(x => new MailboxAddress(x.Name, x.Address)));
                message.Subject = emailMessage.Subject;
                message.Body    = new BodyBuilder
                {
                    HtmlBody = emailMessage.Body
                }.ToMessageBody();;

                using var smtpClient = new SmtpClient();
                await smtpClient.ConnectAsync(_config.SmtpServer, _config.SmtpPort, _config.EnableSsl);

                await smtpClient.AuthenticateAsync(_config.SmtpUsername, _config.SmtpPassword);

                await smtpClient.SendAsync(message).ConfigureAwait(false);

                await smtpClient.DisconnectAsync(true);
            }
        }
Beispiel #22
0
        static public async Task SendEmailAsync(string email, string from, string subject, string message)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress(from, "*****@*****.**"));
            emailMessage.To.Add(new MailboxAddress("", email));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = message
            };
            using (var client = new SmtpClient())
            {
                //client.ServerCertificateValidationCallback = (s, c, h, e) => true;
                await client.ConnectAsync("smtp.yandex.ru", 587, false);

                await client.AuthenticateAsync("*****@*****.**", "4Thehorde!!!!");

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
Beispiel #23
0
        public async Task SendEmailAsync(string email, string subject, string message)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress(_cfg["SmtpConfig:SenderName"], _cfg["SmtpConfig:SenderMail"]));
            emailMessage.To.Add(new MailboxAddress(string.Empty, email));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = message
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync(_cfg["SmtpConfig:Host"], Int32.Parse(_cfg["SmtpConfig:Port"]), true);

                await client.AuthenticateAsync(_cfg["SmtpConfig:SenderMail"], _cfg["SmtpConfig:Password"]);

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
Beispiel #24
0
        public async Task SendEmailAsync(string email, string subject, string message)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress("Адміністрація сайта", "*****@*****.**"));
            emailMessage.To.Add(new MailboxAddress("", email));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = message
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync("smtp.gmail.com", 465, true);

                await client.AuthenticateAsync("*****@*****.**", "big12345");

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
Beispiel #25
0
        public async Task SendEmailAsync(string email, string subject, string message)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress("Администрация сайта", "*****@*****.**"));
            emailMessage.To.Add(new MailboxAddress("", email));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = message
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync("smtp.yandex.by", 25, false);

                await client.AuthenticateAsync("*****@*****.**", "password");

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
        public async Task SendAsync(string email, string subject, string message)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress(_options.Name, _options.Adress));
            emailMessage.To.Add(new MailboxAddress("", email));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = message
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync(_options.Smtp, _options.Port, _options.UseSsl);

                await client.AuthenticateAsync(_options.UserName, _options.Password);

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
Beispiel #27
0
        public async Task SendEmailAsync(string email, string subject, string message)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress("", "*****@*****.**"));
            emailMessage.To.Add(new MailboxAddress("", email));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = message
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync("smtp.gmail.com", 465, true);

                await client.AuthenticateAsync("*****@*****.**", "123xxx123");

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
Beispiel #28
0
        public async Task SendEmailAsync(string email, string subject, string message)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress("Task Tracking System", "*****@*****.**"));
            emailMessage.To.Add(new MailboxAddress("", email));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = message
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync("smtp.mail.ru", 25, false);

                await client.AuthenticateAsync("*****@*****.**", "sdn@25051999");

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
Beispiel #29
0
        /// <summary>
        /// Send email
        /// 发送电子邮件
        /// </summary>
        /// <param name="message">Message</param>
        /// <param name="token">Cancellation token</param>
        /// <returns>Task</returns>
        public virtual async Task SendAsync(MimeMessage message, CancellationToken token = default)
        {
            // Format the message
            FormatMessage(message);

            // Client
            using var client = new SmtpClient();

            // Connection
            await client.ConnectAsync(Settings.Host, Settings.Port, Settings.UseSsl, token);

            // Auth
            if (!string.IsNullOrEmpty(Settings.UserName) && !string.IsNullOrEmpty(Settings.Password))
            {
                await client.AuthenticateAsync(Settings.UserName, Settings.Password, token);
            }

            // Send
            await client.SendAsync(message, token);

            // Disconnect
            await client.DisconnectAsync(true, token);
        }
        public async Task SendEmailAsync(string receiver, string subject, string body)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress(_sender));
            emailMessage.To.Add(new MailboxAddress(receiver));
            emailMessage.Subject = subject;
            emailMessage.Body    = new TextPart(TextFormat.Text)
            {
                Text = body
            };

            using (var smtpClient = new SmtpClient())
            {
                await smtpClient.ConnectAsync(_smtpServer, _smtpPort);

                await smtpClient.AuthenticateAsync(_username, _password);

                await smtpClient.SendAsync(emailMessage);

                await smtpClient.DisconnectAsync(true);
            }
        }