Reputation: 1
currently I am trying to use the Phpmailer for a school project. I do not know a lot about server or nginx. When I use the code for the phpmailer nothing seems to happen, but after a while I get this error allert:
[error] 8085#0: *71722 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 2.203.50.189, server: delivery.nginx.xxxxxxxxxxxxxxxxxxxx.net, request: "POST /register.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "xxxxxxxxxxxxxxxxxxxxxxxx.net", referrer: "http://xxxxxxxxxxxxxxxxxxxxxx.net"
It would be awesome if someone knows how to fix this problem. Thanks alot!!
The code for the phpmailer:
<?php
use PHPMailer\PHPMailer\PHPMailer;
date_default_timezone_set('Etc/UTC');
require 'vendor/autoload.php';
//Create a new PHPMailer instance
//$mailer = new PHPMailer(true);
$mail = new PHPMailer();
//Set who the message is to be sent from
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
//Set the hostname of the mail server
$mail->Host = 'xxxxxxxxxxxxxx';
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = 587;
$mail->SMTPSecure = "ssl";
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication
$mail->Username = 'xxxxxxxxxxxxxxxxx';
//Password to use for SMTP authentication
$mail->Password = 'xxxxxxxxxxxxxxxxx';
$mail->setFrom('xxxxxxxxxxxxxxxxx', 'xxxxxxxxx');
//Set an alternative reply-to address
//$mail->addReplyTo('[email protected]', 'First Last');
//Set who the message is to be sent to
$mail->AddAddress("xxxxxxxxxxxxx");
//Set the subject line
//$mail->Subject = 'PHPMailer SMTP test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
//$mail->Body = 'Test';
$mail->msgHTML("test");
//Replace the plain text body with one created manually
//$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
//$mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
Upvotes: 0
Views: 192
Reputation: 65
from https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
you must use
port 465 with ssl
or
port 587 with tls
you are currently using ssl with 587
Upvotes: 0