9951 explained code solutions for 126 technologies


phpmailerHow do I set up PHPMailer to use NTLM authentication?


PHPMailer can be configured to use NTLM authentication with the following steps:

  1. Install the ntlm_sasl library by running composer require eustasy/ntlm_sasl

  2. Create a new instance of the PHPMailer class and set the mailer to smtp

$mail = new PHPMailer();
$mail->isSMTP();
  1. Set the SMTP authentication type to NTLM
$mail->AuthType = 'NTLM';
  1. Set the SMTP host
$mail->Host = 'smtp.example.com';
  1. Set the SMTP username and password
$mail->Username = 'username';
$mail->Password = 'password';
  1. Set the NTLM authentication type
$mail->AuthType = 'NTLM';
  1. Finally, send the email
$mail->send();

For more information on how to use PHPMailer with NTLM authentication, please refer to the PHPMailer documentation.

Edit this code on GitHub