. Advertisement .
..3..
. Advertisement .
..4..
How to solve the problem – smtp connect() failed. https://github.com/phpmailer/phpmailer/wiki/troubleshooting?
I have the sample detail:
<?php
include('header.php');
require 'PHPMailerAutoload.php';
$message='';
if(isset($_POST["submit"]))
{
$path='upload/'.$_FILES["resume"]["name"];
move_uploaded_file($_FILES["resume"]["tmp_name"], $path);
$mail = new PHPMailer;
$mail->SMTPDebug = 0; // Enable verbose debug output
$mail->isSMTP(); // mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'mypasswordgoeshere'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->From=$_POST['email'];
$mail->FromName=$_POST['name'];
$mail->setFrom($_POST['email']);
$mail->addAddress('[email protected]');
$mail->AddCC($_POST['name'],$_POST['email']);
$mail->WordWrap=50;
$mail->AddAttachment($path);
$mail->Subject='application for job';
// Add a recipient
// Name is optional
$mail->addReplyTo($_POST['email']);
$mail->isHTML(true); // Set email format to HTML
//$mail->Subject = $_POST['subject'];
$mail->Body = $_POST['message'];
$mail->AltBody = $_POST['message'];
if(!$mail->send()) {
echo '<script>alert("Message could not be sent.")</script>';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo '<script>alert("Message has been sent");
window.location.href="career.php";
</script>';
}
}
?>
While I was running it, I found the warning message:
Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
That is my question in my midterm exam, and it is urgent.
I searched the solutions on some websites, but I didn’t get it. I may miss any line or other changes. I appreciate your assistance!
The cause: This error indicates that your script is unable to connect to your SMTP server.
The solution: I recommend starting over: get the most recent version of PHPMailer, follow one of the available examples, and tweak it to fit your own server. Set
$mail->SMTPDebug = 3;
to see what happens when you try to connect to the server. All of this is in the issue template (which you erased) as well as the troubleshooting instructions to which your error message refers.Have you changed your gmail security settings? Change your less secure app access to turn it on