SMTP -> ERROR: Failed to connect to server: (0) in PHP malier -
following php email code , works fine still today.
require_once('_lib/class.phpmailer.php'); include 'func/db_connect.php'; error_reporting(e_all); ini_set('display_errors', 1); function supervisormail(){ global $error; $mail = new phpmailer(); $mail->issmtp(); $mail->smtpdebug = 2; $mail->smtpauth = true; $mail->smtpsecure = 'ssl'; $mail->host = 'smtp.gmail.com'; $mail->port = 465; $mail->username = "*****@gmail.com"; $mail->password = "*****"; $mail->setfrom("****@gmail.com", "employee leave management system"); }
but not work without changing of code , makes following error.
smtp -> error: failed connect server: (0) smtp error: not connect smtp host. message not sent. mailer error: smtp error: not connect smtp host.
i not able find solution. how can fixed this.
try work
$mail = new phpmailer(); $mail->issmtp(); $mail->smtpdebug = 1; $mail->smtpauth = true; $mail->smtpsecure = 'ssl'; $mail->host = "smtp.gmail.com"; $mail->port = 465; $mail->ishtml(true); $mail->username = "*******@gmail.com"; $mail->password = "*******";
you have change in gmail.in account permissions section, find access less secure apps , enable it.