Base solution for your next web application
Open Closed

Can AspNetZero support Office365 SMTP email using TLS #4420


User avatar
0
itzoar2 created

Hi base on the below link <a class="postlink" href="https://itservices.usc.edu/office365/emailclients/">https://itservices.usc.edu/office365/emailclients/</a>

Office365 is using TLS Encryption Method and Port Number 587

It seems the SMTP client in Aspnetzero doesn't support TLS?


10 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team
  • User Avatar
    0
    vladsd created

    The issue is here with MailKit, here is Connect that fixes the issue client.Connect( _smtpEmailSenderConfiguration.Host, _smtpEmailSenderConfiguration.Port, //_smtpEmailSenderConfiguration.EnableSsl SecureSocketOptions.Auto );

  • User Avatar
    0
    [email protected] created

    <cite>aaron: </cite> Duplicate of #3962@b1758ffc-c5d6-4949-bfc8-a9bc10b108f6

    This is misleading answer. I should not change the code in order to make it work.

    The very basic code I've tested worked perfectly!

    SmtpClient client = new SmtpClient("smtp.office365.com", 587);
    client.UseDefaultCredentials = false;
    client.Credentials = new NetworkCredential("[mail]", [password]");
    client.EnableSsl = true;
    MailMessage mailMessage = new MailMessage();
    mailMessage.From = new MailAddress("[mail]");
    mailMessage.To.Add("[email protected]");
    mailMessage.Body = "body";
    mailMessage.Subject = "subject";
    client.Send(mailMessage);
    

    Should I replace your code with this to make it work!

  • User Avatar
    0
    aaron created
    Support Team

    This is misleading answer.

    No, I just pointed to another person's solution for the same issue.

    I should not change the code in order to make it work.

    The very basic code I've tested worked perfectly!

    Should I replace your code with this to make it work!

    If it works for you without any change, that's great.

  • User Avatar
    0
    Homam created

    Actually I am expecting a fix from your side. I think it should work without changing code and overriding the existing library.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @Homam,

    This is a problem of MailKit, we don't wnat to change its behaviour. Using the code you shared would be a better choice in this case.

  • User Avatar
    0
    Homam created

    The porblem has been fixed after upgrading to ABP 3.4. This was the solution ;)

  • User Avatar
    0
    aaron created
    Support Team

    Thanks for letting us know!

  • User Avatar
    0
    itzoar2 created

    So may i know what is the ultimate method to use Office365 SMTP email using TLS?

    <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Email-Sending">https://aspnetboilerplate.com/Pages/Doc ... il-Sending</a>

    does it mean i should use

    Abp.MailKit NuGet package

    And replace the IMailKitSmtpBuilder interface with your own implementation

    using the above code to config the smtp client ?

  • User Avatar
    0
    aaron created
    Support Team

    @itzoar2

    <cite>Homam: </cite> The problem has been fixed after upgrading to ABP 3.4. This was the solution ;)