I'm new to website development and using Linux+Apache+PHP for my website and want to use PHPMailer to send e-mail. This is my code for index.php:
<?php
header("content-type:text/html;charset=utf-8");
date_default_timezone_set("Etc/GMT-8");
require_once"class.smtp.php";
require_once"class.phpmailer.php";
$mail = new PHPMailer;
$mail->IsSMTP(); // send via SMTP
$mail->Host = "smtpdm.aliyun.com"; // SMTP servers
$mail->PORT = 465;
$mail->SMTPDebug = 2;
$mail->SMTPAuth = true;
$mail->Username = "web@info.jingdaninternet.com"; // SMTP username
$mail->Password = "Mypassord"; // SMTP password
$mail->From = "web@info.jingdaninternet.com";
$mail->FromName = "Test";
$mail->CharSet = "UTF-8";
$mail->Encoding = "base64";
$mail->AddAddress("info@jingdaninternet.com","Receiver");
$mail->IsHTML(true); // send as HTML
$mail->Subject = "New Message";
$mail->Body = "Test";
if(!$mail->Send())
{
echo "Wrong!";
exit;
}
else {
echo "Success!";
}
This script works on localhost, but when I upload this to server it doesn't work and shows:
SMTP ERROR: Failed to connect to server : Connection timed out (110).
Does anyone know how to solve this problem? Thanks!