-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEmailSender.cs
38 lines (33 loc) · 1.16 KB
/
EmailSender.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using Microsoft.AspNetCore.Identity.UI.Services;
using System.Net;
using System.Net.Mail;
using System.Threading.Tasks;
namespace RazorStripe.Services
{
// This class is used by the application to send email for account confirmation and password
// reset. For more details see https://go.microsoft.com/fwlink/?LinkID=532713
public class EmailSender : IEmailSender
{
public Task SendEmailAsync(string email, string subject, string message)
{
SmtpClient client = new SmtpClient("smtp.mailgun.org", 587)
{
UseDefaultCredentials = false,
//add credentials
Credentials = new NetworkCredential("[email protected]", "xxxx"),
EnableSsl = true
};
MailMessage mailMessage = new MailMessage
{
//from address
From = new MailAddress("[email protected]"),
Body = message,
IsBodyHtml = true,
Subject = subject
};
mailMessage.To.Add(email);
client.Send(mailMessage);
return Task.CompletedTask;
}
}
}