Unable to send mails using smtp

I am using Cloudflare for SSL but i am unable to use smtp for sending mails below is my code

ini_set('display_errors', '1');

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';

// Instantiation and passing [ICODE]true[/ICODE] enables exceptions
$mail = new PHPMailer(true);

try {
 //Server settings
 $mail->SMTPDebug = 2; // Enable verbose debug output
 $mail->isSMTP(); // Set mailer to use SMTP
 $mail->Host = 'mail.late90s.in'; // Specify main and backup SMTP servers
 $mail->SMTPAuth = true; // Enable SMTP authentication
 $mail->Username = '[email protected]'; // SMTP username
 $mail->Password = 'x3jOoLbucj%g'; // SMTP password
 $mail->SMTPSecure = 'tls'; // Enable TLS encryption, [ICODE]ssl[/ICODE] also accepted
 $mail->Port = 587; // TCP port to connect to

 $mail->setFrom('[email protected]', 'Mailer');
 $mail->addAddress('[email protected]', 'Joe User');
 $mail->addReplyTo('[email protected]', 'Information');
//  $mail->addCC('[email protected]');
//  $mail->addBCC('[email protected]');

// Attachments
//  $mail->addAttachment('/home/cpanelusername/attachment.txt'); // Add attachments
//  $mail->addAttachment('/home/cpanelusername/image.jpg', 'new.jpg'); // Optional name

// Content
 $mail->isHTML(true); // Set email format to HTML
 $mail->Subject = 'Here is the subject';
 $mail->Body = 'This is the HTML message body <b>in bold!</b>';
 $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

 echo 'Message has been sent';

} catch (Exception $e) {
 echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";

mail.late90s.in is the only place where your Cloudflare settings could cause a problem, and that is correctly set to “DNS only” and not “Proxied” so the problem isn’t there.

The server at mail.late90s.in is answering on port 587 so any issue is either in your code or the server configuration.

What error do you get?

1 Like

i am getting A timeout occurred Error code 524

please check above image

My hosting is in godaddy and i am using cpanel should i make any changes in cpanel to amke it work.

The pointed site works fine without having error as I see this:

It looks to me that you are seeing the cached version.

Cloudflare SSL won’t affect sending emails. It has to do with the code. Here’s the fine tuned code:

didn’t work

This is my dns records

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