Base solution for your next web application
Open Closed

SMTP Gmail #5720


User avatar
0
ncvitanovic created

Hi,

What are the settings for sending e-mails over Gmail?

It should be:

smtp.gmail.com Requires SSL: Yes Requires TLS: Yes (if available) Requires Authentication: Yes Port for TLS/STARTTLS: 587

I tried also CustomMailKitSmtpBuilder because of STARTTLS: https://forum.aspnetboilerplate.com/viewtopic.php?f=5&t=10543 But without success.

I tried on localhost and Azure.

Thanks, Niko


1 Answer(s)
  • User Avatar
    0
    ncvitanovic created

    I got it working:

    smtp.gmail.com SSL OFF 587

    AppCoreModule:

    Configuration.ReplaceService<IMailKitSmtpBuilder, CustomMailKitSmtpBuilder>(DependencyLifeStyle.Transient);

    ...

    public CustomMailKitSmtpBuilder(ISmtpEmailSenderConfiguration smtpEmailSenderConfiguration, IAbpMailKitConfiguration abpMailKitConfiguration) : base(smtpEmailSenderConfiguration, abpMailKitConfiguration) { }

    protected override void ConfigureClient(SmtpClient client) { client.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true; base.ConfigureClient(client); }

    Slightly different from aspboilerplate: https://aspnetboilerplate.com/Pages/Documents/Email-Sending