PHPMailer Updated for all Versions


PHPMailer updation for All versions

// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailerPHPMailerPHPMailer;
//use PHPMailerPHPMailerException;
require 'phpmailer/src/Exception.php';
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/SMTP.php';
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
//$mail->SMTPDebug = 2;
$mail->SMTPSecure = 'tls';
$mail->Host = '';
$mail->Port = 587;
//or more succinctly:
$mail->Host = 'tls://';
//Set the hostname of the mail server
$mail->Host = '';
// use
// $mail->Host = gethostbyname('');
// if your network does not support SMTP over IPv6
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 587;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
 $mail->SMTPOptions = array(
        'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false,
            'allow_self_signed' => true
//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "";
//Password to use for SMTP authentication
$mail->Password = "";
//Set who the message is to be sent from
$mail->setFrom('mailid', 'First Last');
//Set who the message is to be sent to
$mail->addAddress('id1', 'John Doe');
$mail->addAddress('id2', 'John Doe');
//Set the subject line
$mail->Subject = 'Web Checking Mail';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML("Test message");
//send the message, check for errors
if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";


Download code 


Your email address will not be published. Required fields are marked *

Be the first to comment. :)

The primary motive of our company is to provide beyond satisfactory results .

Request a free consultation quote