Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Known issue: MailTarget + SSL + port 465 isn't working #1226

Closed
304NotModified opened this issue Feb 7, 2016 · 14 comments
Closed

Known issue: MailTarget + SSL + port 465 isn't working #1226

304NotModified opened this issue Feb 7, 2016 · 14 comments

Comments

@304NotModified
Copy link
Member

This could be a .Net bug, described at: http://blogs.msdn.com/b/webdav_101/archive/2008/06/02/system-net-mail-with-ssl-to-authenticate-against-port-465.aspx

TL;DR: SSL + port 465 (implicit SSL) is not supported in .Net. You can only use SSL + port 25 (explicit SSL)

See http://stackoverflow.com/questions/35228313/nlog-mail-target-timeouts/35235850#35235850

@304NotModified
Copy link
Member Author

Mail api which support implicit ssl

https://www.nuget.org/packages/AIM

Edit bad reviews for AIM

@304NotModified
Copy link
Member Author

Looks nice: https://github.com/jstedfast/MailKit

@304NotModified
Copy link
Member Author

Will close this as this is a known issue as it's polluting the issue list - there is no action for us here.

@304NotModified
Copy link
Member Author

There is now a NLog.MailKit package:

https://www.nuget.org/packages/NLog.MailKit

@stlsw
Copy link

stlsw commented Nov 15, 2017

NLog.MailKit Works like charm on net 4.5. thanks !!

@neooleg
Copy link

neooleg commented Nov 23, 2017

@304NotModified, could you pls elaborate how to use SSL (gmail) with NLog.MailKit?

@304NotModified
Copy link
Member Author

304NotModified commented Nov 23, 2017

Install the package: Install-Package NLog.MailKit and add to your nlog.config:

<extensions>
    <add assembly="NLog.MailKit"/>
</extensions>

See https://github.com/NLog/NLog.MailKit/blob/master/README.md

Use the target "mail" and config options can be found here: https://github.com/NLog/NLog/wiki/Mail-Target

@neooleg
Copy link

neooleg commented Nov 23, 2017

I did it and did follow the link which mentions

Note: port 465 isn't working with SSL.

And redirects to this page.

Do you have a piece of config which configures gmail w/ SSL?

@304NotModified
Copy link
Member Author

@304NotModified
Copy link
Member Author

So use port 587

@gaazkam
Copy link

gaazkam commented Jun 18, 2021

@304NotModified

Why does https://github.com/NLog/NLog/wiki/Mail-Target still say:

Note: port 465 isn't working with SSL. See issue 1226

My understanding is that as long as MailKit is used there should be no problems with port 465 and SSL?

I just tested it and it seems to work fine:

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
      autoReload="true"
      throwExceptions="true">

  <targets>
    <target name="logconsole" xsi:type="Console" />
    <target name="logmail" xsi:type="Mail"
            subject="Email logging test"
            to="redacted"
            from="redacted"
            smtpUserName="redacted"
            enableSsl="true"
            secureSocketOption="SslOnConnect"
            smtpPassword="redacted"
            smtpAuthentication="Basic"
            smtpServer="redacted"
            smtpPort="465"
            timeout="100000"
            />
  </targets>

  <rules>
    <logger name="*" minlevel="Debug" writeTo="logconsole" />
    <logger name="*" minlevel="Warning" writeTo="logmail" />
  </rules>

  <extensions>
    <add assembly="NLog.MailKit"/>
  </extensions>
</nlog>

@304NotModified
Copy link
Member Author

Thanks, please update the wiki. It is indeed working for NLog mailkit (thanks for the confirm!).

PS: The page is shared for the mail target in NLog and NLog mailkit

@gaazkam
Copy link

gaazkam commented Jun 20, 2021

Done.

@304NotModified
Copy link
Member Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants