Open Closed

Email not sending despite testing SMTP info and applying recommended fixes on forum .. #6095


0
jchester26 created

Hi,

Emails are not sending and I would like some help trying to reolve as I am spending a lot of time with no success. I have reviewed the support forum and tried several fixes but still no success.

  • I have tested all of my SMTP settings sing SMTPProbe and that succesfully sends emails from the same machine (host, port, user, password, authentication)
  • I have commented out '//Configuration.ReplaceService<IEmailSender, NullEmailSender>(DependencyLifeStyle.Transient);' in Module Preinitialization so that emails are sent in debug mode
  • I have added 'Configuration.Modules.AbpMailKit().SecureSocketOption = SecureSocketOptions.Auto;' line to Preinitiialization in XYZCoreModule.cs
  • I have not added any code to XYZSmtpEmailSenderConfiguration class in XYZSmtpEmailSenderConfiguration.cs

The log file records the following;

`ERROR 2018-12-05 09:39:43,418 [56   ] Mvc.ExceptionHandling.AbpExceptionFilter - An error occurred while attempting to establish an SSL or TLS connection.

The SSL certificate presented by the server is not trusted by the system for one or more of the following reasons:
1. The server is using a self-signed certificate which cannot be verified.
2. The local system is missing a Root or Intermediate certificate needed to verify the server's certificate.
3. The certificate presented by the server is expired or invalid.

See https://github.com/jstedfast/MailKit/blob/master/FAQ.md#InvalidSslCertificate for possible solutions.
MailKit.Security.SslHandshakeException: An error occurred while attempting to establish an SSL or TLS connection.

The SSL certificate presented by the server is not trusted by the system for one or more of the following reasons:
1. The server is using a self-signed certificate which cannot be verified.
2. The local system is missing a Root or Intermediate certificate needed to verify the server's certificate.
3. The certificate presented by the server is expired or invalid.

See https://github.com/jstedfast/MailKit/blob/master/FAQ.md#InvalidSslCertificate for possible solutions. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.`

When I investigated that problem, the recommendation was to add the Configuration.Modules.AbpMailKit().SecureSocketOption = SecureSocketOptions.Auto; setting in the module preinitialisation, which I have done.

I am using SendGrid SMTP server, but I am not sure that is the issue as I can succesfully send an Email using STMPProbe app from the same machine. the STMP setting for that are smtp.sendgrid.net, port 587, username apikey and pwd [not included here]

Can anyone offer any more advice?

Thanks!


7 Answer(s)
  • 0
    jchester26 created

    Hi,

    Update. I have tried using Gmail SMTP as suggested in thos post by @ismcagdas https://support.aspnetzero.com/QA/Questions/4360

    The exact same error occurs and the exact same log file entries.

    Any help from support?

    Thanks

    J

  • 0
    ismcagdas created

    Hi @jchester26

    This problem should be fixed via https://github.com/aspnetzero/aspnet-zero-core/commit/a42ec83d307c35cc5e3b68c51678acc647e75b5b.

    Could you try that in your solution as well ?

  • 0
    jchester26 created

    Hi @ismcagdas

    I get a pgae not found when going to the link you posted.

  • 0
    jchester26 created

    Hi @ismcagdas. OK got the page now.

    I have made the changes to module preinitialisation. However the file AbpZeroTemplateMailKitSmtpBuilder.cs does not exist at this path, I have

    src/XYZ.Core/Emailing/XYZSmtpEmailSenderConfiguration.cs

    Shall I make the changes in that file or create a new XYZMailKitSmtpBuilder.cs file?

  • 0
    jchester26 created

    Hi @ismcagdas

    Yes! That worked thank you. I added the new code as an additonal public class in my existing file.

    Just one final question. When I first changed it I was using the wrong port number and an exception was thrown in the IDE and I had to continue. Is that becuase I am in debug mode? I would not want the system to stop if an exception was thown in production for a timeout if the SMTP server was unavailable.

  • 0
    ismcagdas created

    When I first changed it I was using the wrong port number and an exception was thrown in the IDE and I had to continue

    Yes, if you were debugging the source code, this is the expected behaviour. If you run the project using CTRL + F5 or if your project is running in the production, you will not see such a heavior.

  • 0
    jaycee26 created

    Thank you for your help.