【发布时间】:2015-02-24 23:25:52
【问题描述】:
我的网站在一个虚拟服务器上,一切正常!我将我的主机转移到 GoDaddy,当我给自己发送一封电子邮件以检查它是否有效时,它会引发此错误:
SMTP -> 错误:无法连接到服务器:连接被拒绝 (111) 以下发件人地址失败:root@localhost : 未连接时调用 Mail() 邮件程序错误:以下发件人地址失败:root@localhost : 未连接时调用 Mail()
正如我所说,它适用于我的旧主机,我已经在 gmail 端做了必要的事情,我的凭据是 100% 正确的。但不是我新的 1 我要配置php.ini文件吗?
require_once('includes/class.phpmailer.php');
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'tls'; // secure transfer enabled REQUIRED for GMail
$mail->Host = "smtp.gmail.com";
$mail->Port = 587; // or 587
$mail->IsHTML(true);
$mail->Username = "user@gmail.com";
$mail->Password = "password";
$mail->Subject = "Sponsorship enquiry";
$mail->Body = "<p>Sponsorship form details:</p>";
$mail->Body .= "<p>name: ".$name."</p>";
$mail->Body .= "<p>email: ".$email."</p>";
$mail->Body .= "<p>sport: ".$sport."</p>";
$mail->Body .= "<p>message: ".$message."</p>";
$mail->AddAddress("exeuity@gmail.com");
if(!$mail->Send()){
echo "Mailer Error: " . $mail->ErrorInfo;
}
else{
$_SESSION['success'] = "Email successfully sent AIM will be in contact with you shortly!";
header("location:athletes.php");
exit();
}
【问题讨论】:
标签: php email hosting phpmailer