gpt4 book ai didi

GoDaddy Linux Shared 上的 PHP 尝试通过 GMAIL SMTP 发送

转载 作者:可可西里 更新时间:2023-11-01 12:22:52 25 4
gpt4 key购买 nike

为此,我尝试了 StackOverflow 和其他网站上发布的每一个脚本/代码/方法,但没有成功。我在 GoDaddy 上托管。我已经设置了一个 Google App 帐户,设置了 MX 记录所需的一切(为此使用 GoDaddy 工具),甚至尝试从我网站的 GMAIL 界面发送一些电子邮件,以及通过我的一个 unix 终端上的 SMTP机器。一切正常。

但是,当我尝试使用 PHP 时,它没有!是不是 GoDaddy 以某种方式阻止了它?

我总是收到:

SMTP -> ERROR: Failed to connect to server: Connection refused (111) SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.

这是我用于 PHPMailer 的代码:

<html>
<head>
<title>PHPMailer - SMTP (Gmail) advanced test</title>
</head>
<body>
<?php
require_once('../class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch

$mail->IsSMTP(); // telling the class to use SMTP

try {
$mail->Host = "smtp.gmail.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "MYFROMADDRESSHERE"; // GMAIL username
$mail->Password = "MYFROMPASSWORDHERE"; // GMAIL password
$mail->AddReplyTo('MYFROMADDRESSHERE', 'Sender Name');
$mail->AddAddress('TESTTOADDRESSHERE', 'Recipient Name');
$mail->SetFrom('MYFROMADDRESSHERE', 'Sender Name');
$mail->AddReplyTo('MYFROMADDRESSHERE', 'Sender Name');
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->MsgHTML(file_get_contents('contents.html'));
$mail->AddAttachment('images/phpmailer.gif'); // attachment
$mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
$mail->Send();
echo "Message Sent OK</p>\n";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
?>
</html>

谢谢!

最佳答案

如前所述,GoDaddy has been known to block outgoing SSL SMTP connections赞成强制您使用他们自己的外发邮件服务器。

这几乎只是冰山一角,关于 GoDaddy 作为一家公司、注册商和网络托管商的巨大困境。开除他们。

关于GoDaddy Linux Shared 上的 PHP 尝试通过 GMAIL SMTP 发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5440026/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com