14

I have symfony project with swiftMailer bundle. I was trying to send email via swiftmailer using NTLM auth. But I have not found a way to turn on NTLM via configuration of the bundle.

After struggling with it I have found solution

First solution

current($this->get('mailer')->getTransport()->getExtensionHandlers())
    ->setAuthenticators([new \Swift_Transport_Esmtp_Auth_NTLMAuthenticator()]);

Comment spool in config.yml

#    spool:     { type: memory }

But it's look a little bit weird.

Second solution

Remove SwiftMailer bundle and use swiftMailer directly, because ntlm auth type activated by default.

Is there a better way to use NTLM auth type?

Peter Matisko
  • 2,113
  • 1
  • 24
  • 47
sectus
  • 15,605
  • 5
  • 55
  • 97
  • 4
    Your current solution/hack takes 1 line of code... As long as NTLM will not be supported by the swift mailer bundle, I doubt you could find a better solution... – Jules Lamur Nov 15 '16 at 10:18
  • @Kadriles, I mean via events or/and config. With working spool. – sectus Nov 18 '16 at 03:40
  • symfony.com/doc/current/reference/configuration/swiftmailer.html#auth-mode - Valid values are plain, login, cram-md5, or null. computer says no for the moment directly from the config. I did find in vendor/swiftmailer/swiftmailer/lib/preferences.php. Could you make your declaration in this file? I know it's in the vendor file and probably be overwritten on update but, if you want cleaner code, worth a shot and then leaving a note – Simon Nov 18 '16 at 07:11
  • According to this question http://stackoverflow.com/questions/22502058/how-to-correctly-configure-symfony2-swiftmailer-bundle-to-work-with-smtp-server?rq=1 you can use smtp transport and default auth_mode. – Grzegorz Krauze Nov 27 '16 at 11:46

1 Answers1

3

I created pull request which got approved.

Since version v3.0.4 you can use

  auth_mode: ntlm

You can install v3.0.4 version using command

composer require symfony/swiftmailer-bundle:^3.0.4
mleko
  • 11,650
  • 6
  • 50
  • 71