Asked by:
SendGird Alternative

Question
-
User-1671627117 posted
After completing the excellent tutorial here, I found that SendGird is extremely slow. It always takes at least 12 minutes to send email.
In some cases, email is never received.
There is a quick, easy alternative to SendGird is Gmail with the code below and remove configSendGridasync
public async Task SendAsync(IdentityMessage message)
{
// Plug in your email service here to send an email.
var sentFrom = "noreply@ourdoamin.com";
// Configure the client:
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("smtp.gmail.com");
client.Port = 587;
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
// Creatte the credentials:
System.Net.NetworkCredential credentials = new NetworkCredential(
ConfigurationManager.AppSettings["mailAccount"],
ConfigurationManager.AppSettings["mailPassword"]
);
client.EnableSsl = true;
client.Credentials = credentials;
// Create the message:
var mail = new System.Net.Mail.MailMessage(sentFrom, message.Destination);
mail.Subject = message.Subject;
mail.Body = message.Body;
await client.SendMailAsync(mail);
}There is two important security factors to consider:
1. Create a dummy gmail, do not use your own because you need to set the gmail account security to lesssecureapps:
Click on this link when with your dummy gmail only: https://www.google.com/settings/security/lesssecureapps
2. Your gmail account and password should be in global Web.Config as per the tutorial
<code>
<appSettings>
.....
<add key="mailAccount" value="your gmail account" />
<add key="mailPassword" value="your gmail password" />.....
</appSettings>
</code>
Gmail sends email within 1 minute, normally less than 10 secs. SendGrid is a joke.
Friday, November 28, 2014 12:56 AM
All replies
-
User1826113580 posted
Hi Tony,
Fortunately, I found your post and it helped me a great deal! For a variety of reasons I didn't want to use the SendGrid method in the tutorial. Your write-up was very clear and just what I needed to use gmail. Thank you very much for posting this!
Tuesday, April 21, 2015 9:16 PM -
User-1851835828 posted
Cheers Tony. Managed to get this working.
My only question is does this line of code actually do anything?
var sentFrom = "noreply@ourdoamin.com";
All of my test emails come from the Gmail account I'm using the send the emails from. How can we make the emails appear to come from a different address and what steps should we take to ensure that these emails don't go straight to people's spam folders?
Thanks.
Friday, December 11, 2015 4:29 PM -
User1308395552 posted
Thanks a lot :)
Thats way better than using sendgrid.Tuesday, March 1, 2016 5:56 PM