9951 explained code solutions for 126 technologies

phpmailerHow do I configure PHPMailer to use TLS 1.2?

  1. Download and install PHPMailer.
  2. Create a PHPMailer instance and set the SMTPSecure property to 'tls':
$mail = new PHPMailer;
$mail->SMTPSecure = 'tls';
  1. Set the SMTPAutoTLS property to true to enable TLS 1.2:
$mail->SMTPAutoTLS = true;
  1. Set the Host property to the SMTP hostname and port of your email provider:
$mail->Host = 'smtp.example.com:587';
  1. Set the SMTPAuth property to true if your email provider requires authentication:
$mail->SMTPAuth = true;
  1. Set the Username and Password properties if authentication is required:
$mail->Username = 'username';
$mail->Password = 'password';
  1. Send the email using the send() method.

Helpful links

Edit this code on GitHub