Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using MimeKit;
- using MailKit.Net.Smtp;
- namespace MyCloud.Helpers
- {
- public static class MailHelper
- {
- public static async Task SendEmail(string email, string subject, string message)
- {
- using 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.Plain)
- {
- Text = message
- };
- using (var client = new SmtpClient())
- {
- await client.ConnectAsync("smtp.mail.ru", 465, true);
- await client.AuthenticateAsync("", "");
- await client.SendAsync(emailMessage);
- await client.DisconnectAsync(true);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement