我是网站开发的新手,我的网站使用Linux + Apache + PHP,并希望使用PHPMailer发送电子邮件。这是我的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!";
}
此脚本适用于localhost,但当我将其上传到服务器时,它不起作用并显示:
SMTP错误:无法连接到服务器:连接超时(110)。
有谁知道如何解决这个问题?谢谢!