SMTP using PHPMailer

I’m using Infinityfree to host on my website

I wanted to set up an email system which uses an email provided by my domain provider (

First of all, I can’t understand what’s the right SMTP server:

  • here it says port 465
  • the MX record is set to port 143
  • the SRV record says port 443
  • the email provider ( says port 25
  • some forums say to try with which would be

None of them works… Where should I find my SMTP server name?

After reading this article I realized that probably php mail() function doesn’t work (also because SMTP from that function isn’t avaiable from Linux servers as far as I know), so I installed PHPMailer.

Now I get an error like this:

SMTP ERROR: Failed to connect to server: Connection timed out (110)
SMTP connect() failed.
Message could not be sent. Mailer Error: SMTP connect() failed.

Could it be related with some InfinityFree restrictions?
Do I have to setup something more from the DNS? (I’m using cloudflare)

InfinityFree does have SMTP, meaning you will have to use an external provider. If you are having trouble with that provider, ask them for help.

What do you mean with external provider?

I got my email from my registar, and it does have SMTP.

Do you mean that I cannot even use it and I have to switch my hosting account?

The hostname and IP address you need to use are the SMTP server name and port. So, looking through the page you linked to, I think the SMTP hostname is and the port is 465. When using pot 465, you should also use the SMTPSecure parameter to ssl.


Thank you for the reply but it does not work anyway.

The page keeps loading for a few minutes and then I get a CloudFlare 524 error page (“A timeout occurred”).

Even before using CloudFlare I got a similar error after a long timeout.

This is the code I’m using:

try {
	$mail->SMTPOptions = [
	$mail->SMTPDebug = "SMTP::DEBUG_SERVER";
    $mail->SMTPAuth = true;
	$mail->SMTPAutoTLS = false;
	$mail->SMTPSecure = "ssl";

	$mail->Host = "";
	$mail->Port = 465;
	$mail->Username = "[email protected]";
    $mail->Password = /*the password of my email*/';

    $mail->setFrom("[email protected]", "Mailer");

    $mail->Subject = "Typed Password Recovery";
    $mail->Body = /*link to tyhe password recovery page*/;
    $mail->AltBody = /*link to tyhe password recovery page*/;

    echo "Message has been sent";

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

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