简体   繁体   中英

SMTP connect() failed

SMTP connect() failed error on my php code.

I already referred all solutions in the stack overflow but nothing will work on my code

I am using php, mysql and server version 5.1.30

No message send to the recipient address.

I already uncomment the below line

extension=php_openssl.dll

php_openssl.dll file exists in the ext folder.

email.php

<?php 
include "PHPMailer-master/class.phpmailer.php";
include "PHPMailer-master/class.smtp.php";
$mail = new PHPMailer(); 
$mail->IsSMTP(); // send via SMTP

$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Host = "smtp.gmail.com";
$mail->port = 465;
echo !extension_loaded('openssl')?"Not Available":"Available";
$mail->Username = "jansiantony92@gmail.com"; // SMTP username
$mail->Password = "xxxxxxxxx"; // SMTP password
$webmaster_email = "asha.it33@gmail.com"; //Reply to this email ID
$email="aasha.vkm@domain.com"; // Recipients email ID
$name="name"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "Webmaster";
$mail->AddAddress($email,$name);
$mail->AddReplyTo($webmaster_email,"Webmaster");
$mail->WordWrap = 50; // set word wrap
//$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment
$mail->IsHTML(true); // send as HTML
$mail->Subject = "This is the subject";
$mail->Body = "Hi,
This is the HTML BODY "; //HTML Body
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}
?>

ssl not loaded is always displayed. Is there is any solution to solve this error

my php.ini file

[mail function]
; For Win32 only.
SMTP = smtp.gmail.com
smtp_port = 25

; For Win32 only.
sendmail_from = jansiantony92@gmail.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path ="\"C:\xampp\sendmail\sendmail.exe\" -t -i"

You need to open the debug; you will be able to see the details of the error message;

$mail->SMTPDebug = 3; 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM