0

I am calling a method that will send an email via SMTP to the user to verify their account. I put this in a try catch block so that if it fails it will give the user an error message. However the time for it to time out is much longer than I would like. I would like to reduce the time for the method to fail to maybe 10 seconds so the user isn't waiting for something that is already going to fail.

Is there a way to shorten the wait time so that it falls into the catch faster?

try
{
    SendVerificationLinkEmail(dbUser.Username, dbUser.ActivationCode.ToString());
}
catch
{
    ViewBag.Message = "There was an error sending your verification email. Please try again later or contact Tech Support.";
    return View("CreateAccount", new UserViewModel());
}
Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
Orangetan
  • 1
  • 1
  • https://stackoverflow.com/q/18597520 – Robert Harvey Aug 22 '19 at 22:51
  • You may want to reduce the time-out of the SMTP client you are using inside your SendVerificationLinkEmail. That way, it will fail quicker. Even better, skip using SMTP and use a transactional email sending service such as Mandrill, SendGrid, MailGun etc. Their API calls will be quicker and fail less than SMTP. – Gary Sep 04 '19 at 10:25

0 Answers0