SMTP using PHPMailer

I’m using Infinityfree to host on my website typed.online.

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

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

  • here it says authsmtp.securemail.pro port 465
  • the MX record is set to mail.register.it port 143
  • the SRV record says ms-it.securemail.pro port 443
  • the email provider (webmail.register.it) says webmailsmtp.register.it port 25
  • some forums say to try with smpt.domain.it which would be authsmtp.register.it

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. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Message could not be sent. Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

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 authsmtp.securemail.pro and the port is 465. When using pot 465, you should also use the SMTPSecure parameter to ssl.

3 Likes

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 = [
		"ssl"=>[
			"verify_peer"=>false,
			"verify_peer_name"=>false,
			"allow_self_signed"=>true
		]
	];
	$mail->SMTPDebug = "SMTP::DEBUG_SERVER";
	$mail->isSMTP();
    $mail->SMTPAuth = true;
	$mail->SMTPAutoTLS = false;
	$mail->SMTPSecure = "ssl";

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

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

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

    $mail->send();
    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.