My log shows as follows
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
017-03-14 09:53:25 SERVER -> CLIENT: 220 smtp.gmail.com CLIENT -> SERVER: EHLO localhost
SERVER -> CLIENT: 250-smtp.gmail.com at your service
CLIENT -> SERVER: STARTTLS
CLIENT -> SERVER: This is the body in plain text for non-HTML mail clients CLIENT -> SERVER: Content-Type: text/html; charset=us-ascii 2017-03-14 09:53:27
CLIENT -> SERVER: This body in bold! 2017-03-14 09:53:27
SERVER -> CLIENT: 221 2.0.0 closing connection 63sm14765080wmg.22 - gsmtp Message has been sent
previous code looks to be as follows . I have changed the port as 465 and SMTPSecure as ssl. I had different error
2017-03-14 07:40:31 SMTP ERROR: Failed to connect to server: (0)
2017-03-14 07:40:31 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
I have made changes in php.ini by adding send email password and name.
<?php
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com';// Specify main and backup SMTP s
$mail->SMTPAuth = true;
$mail->Username = 'sender@gmail.com'; // SMTP user
$mail->Password = 'password'; // SMTP pas
$mail->SMTPSecure = 'ssl'; // Enable TLS 'tls'encryption,
$mail->Port = 465; // TCP port to
$mail->setFrom('sender@gmail.com', 'Eiman');
$mail->addAddress('sender1@gmail.com', 'user1');
$mail->addAddress('sender2@gmail.com'); // Name is optional
//$mail->addReplyTo('info@example.com', 'Information');
//$mail->addCC('cc@example.com');
//$mail->addBCC('bcc@example.com');
//mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Registration Form';
$mail->Body = 'This body <b>in bold!</b>';
$mail->AltBody = 'This is the body in ';
if (!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
Finally i have changed $mail->SMTPDebug = 0; `now there is no error . I didn't receive any mail.