Last active
December 28, 2015 01:39
-
-
Save heitortsergent/7421779 to your computer and use it in GitHub Desktop.
Sendgrid - Unity Email via SMTP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MailMessage mail = new MailMessage(); | |
mail.From = new MailAddress(fromEmail); | |
mail.To.Add(toEmail); | |
mail.Subject = subject; | |
mail.Body = body; | |
mail.Headers.Add("X-SMTPAPI", xsmtpapiJSON); | |
SmtpClient smtpServer = new SmtpClient("smtp.sendgrid.net"); | |
smtpServer.Port = 587; | |
smtpServer.Credentials = new System.Net.NetworkCredential(api_user, api_key) as ICredentialsByHost; | |
smtpServer.EnableSsl = true; | |
ServicePointManager.ServerCertificateValidationCallback = | |
delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) | |
{ return true; }; | |
smtpServer.Send(mail); | |
Debug.Log("Success, email sent through SMTP!"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment