PHPMailer电子邮件有时由于多次测试而无法发送?

时间:2018-08-20 05:17:42

标签: php phpmailer

我遇到邮件问题,有时无法访问所有电子邮件地址。我正在从自己构建的Web应用程序进行测试,该Web应用程序由GoDaddy托管,并具有“豪华”共享托管级别。 通过提交过多的测试电子邮件发送,我是否可能使GoDaddy电子邮件服务器神魂颠倒? 服务器认为我的多个测试是垃圾邮件,是否可能阻止了我的电子邮件?我确实收到了一些电子邮件。...

// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

//Load Composer's autoloader
require 'vendor/autoload.php';

$mail = new PHPMailer(true); // Passing `true` enables exceptions
try {
// Server settings
$mail->SMTPDebug  = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host       = 'xxxxxxxxxxxx.prod.phx3.secureserver.net'; // Specify main and backup SMTP servers
$mail->SMTPAuth   = true; // Enable SMTP authentication
$mail->Username   = 'cpanelusername'; // SMTP username
$mail->Password   = 'cpanelpassword'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port       = 587; // TCP port to connect to

// Recipients - Names are optional - $mail->setFrom('xxxxxxxxxx@cox.net', 'Peter Henry Lee');
$mail->setFrom('xxxxxxxxxx@cox.net'); // From Address
$mail->addAddress('xxxxxxxxxx@cox.net'); // Recipient 1
$mail->addAddress('xxxxx@cox.net'); // Recipient 2
$mail->addCC('xxxxxxx@cox.net'); // Cc 1 Address
$mail->addCC('xxxxxxxx@cox.net'); // Cc 2 Address
$mail->addBCC('xxxxxxxxx@xxxxesigns.com'); // Bcc Address
// $mail->addReplyTo('xxxxxxxxx@xxxxesigns.com'); // Reply-To Address

// Attachments
include 'retrieve_order.php'; // Retrieves PDF
$mail->addAttachment('receipts/' . $newname); // Adds PDF attachment
 // $mail->addAttachment('img/puppy2.png', 'Puppy is cute!'); // Adds Image attachment with optional name

// Content
$newname       = substr($newname, 0, 11);
$l             = $newname;
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the TEST ' . $l . ' subject line';
$mail->Body    = 'This is the TEST ' . $l . ' HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the TEST ' . $l . ' body in plain text for non-HTML mail clients';

// Send mail
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}

0 个答案:

没有答案