Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I am trying to use a free SMTP relay from SendGrid to send emails from my ASP.NET application. I can connect to the server, but when I try to authenticate, I get this error : "The SMTP server has unexpectedly disconnected."
using (var client = new SmtpClient())
client.ServerCertificateValidationCallback =
(sender, certificate, certChainType, errors) => true;
client.AuthenticationMechanisms.Remove("XOAUTH2");
// connection
client.Connect("smtp.host", 465, true);
client.Authenticate("UserName", "Password");//error occurs here
client.Send(email);
client.Disconnect(true);
Once again, I can connect without any problem, but when I try to authenticate, I get the previously mentionned error...
Any suggestions?
Cheers
–
Username: is apikey
(as a hard-coded value 'apikey').
Password: is the apikey you generated from the web, which is a big hashy-like string.
You can find this on their docs. But it was hard to find.
–
I solved my issue changing from SendGrid to gooogle's free SMTP service for all of their users. Simply follow the steps here
and you should be good to go!
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.