Phpmailer not working

My website URL is:

What I’m seeing is:
SSL loaded 2019-03-15 15:36:29 SMTP ERROR: Failed to connect to server: Connection timed out (110) 2019-03-15 15:36:29 SMTP connect() failed. Message could not be sent.
Mailer Error: SMTP connect() failed.

I’m using this software: PHPMailer

php and MySQL

Additional information:

I have set up a website for a LETS scheme. It all works except for the phpmailer installation. I have used phpmailer 5.2 and have also tried the latest version 6.07. I get the error above where no connection is made. I have copied the test mailing page to another server with the exact same phpmailer installations and the mail get sent OK, so I assume there is something different on this infinityfree server. I also tried sendgrid with similar results.

Code for phpmailer 5.2 is below

<?php //use PHPMailer\PHPMailer\PHPMailer; //use PHPMailer\PHPMailer\Exception; //require './PHPMailer/src/Exception.php'; //require './PHPMailer/src/PHPMailer.php'; //require './PHPMailer/src/SMTP.php'; require 'PHPMailer1/PHPMailerAutoload.php'; // semail( to, bcc,subject, html body, plain body) function semail($param1, $param2,$param3,$param4,$param5) { $mail = new PHPMailer; $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = ""; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = "[email protected]"; // SMTP username $mail->Password = "password"; // SMTP password $mail->Port = 25; // TCP port to connect to $mail->From = "[email protected]"; $mail->FromName = "KUTLETS"; $mail->addAddress($param1, ""); // Add a recipient $mail->addCC ("",""); $mail->addBCC($param2, ""); // Add a BCC $mail->addReplyTo("[email protected]", "Accounts"); $mail->SMTPDebug = 2; $mail->WordWrap = 50; // Set word wrap to 50 characters $mail->isHTML(true); // Set email format to HTML $mail->Subject = $param3; $mail->Body = $param4; $mail->AltBody = $param5; if(!$mail->send()) { echo "Message could not be sent.
"; echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message has been sent";} } echo (extension_loaded('openssl')?'SSL loaded':'SSL not loaded')."\n"; semail("[email protected]","[email protected]","Test Subject kutlets","HTML body1","Text body"); ?>

Using port 25 for SMTP is blocked. Please check with your email provider if you can use port 465 or 587 instead.

1 Like

587 works a treat. Many thanks for speedy resulution.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.