2
我正在使用PHPMailer發送電子郵件。當我使用gmail smtp時,它工作正常,但是當我嘗試使用我的域名smtp時,我在屏幕上看到的是'發送的消息!'但我根本沒有收到任何電子郵件。我一直在使用調試器嘗試,它說使用SMTP PHPMailer獲取「域名」電子郵件地址,發送電子郵件但未收到郵件
We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
,這裏是我的代碼
<?php
date_default_timezone_set('Etc/UTC');
//Load PHPMailer dependencies
require_once 'PHPMailerAutoload.php';
require_once 'class.phpmailer.php';
require_once 'class.smtp.php';
/* CONFIGURATION */
$crendentials = array(
'email' => '[email protected]',
'password' => 'xxxxxx'
);
$smtp = array(
'host' => 'secure.ehostpk.com',
'port' => 465,
'username' => $crendentials['email'],
'password' => $crendentials['password'],
'secure' => 'ssl' //SSL or TLS
);
/* TO, SUBJECT, CONTENT */
$to = '[email protected]'; //The 'To' field
$subject = 'This is a test email sent with PHPMailer';
$content = 'This is the HTML message body <b>in bold!</b>';
$mailer = new PHPMailer();
//SMTP Configuration
$mailer->isSMTP();
$mailer->SMTPDebug = 2;
$mailer->SMTPAuth = true; //We need to authenticate
$mailer->Host = $smtp['host'];
$mailer->Port = $smtp['port'];
$mailer->Username = $smtp['username'];
$mailer->Password = $smtp['password'];
$mailer->SMTPSecure = $smtp['secure'];
//Now, send mail :
//From - To :
$mailer->From = $crendentials['email'];
$mailer->FromName = 'Team'; //Optional
$mailer->addAddress($to); // Add a recipient
//Subject - Body :
$mailer->Subject = $subject;
$mailer->Body = $content;
$mailer->isHTML(true); //Mail body contains HTML tags
//Check if mail is sent :
if(!$mailer->send()) {
echo 'Error sending mail : ' . $mailer->ErrorInfo;
} else {
echo 'Message sent !';
}
我尋覓了很多,我不明白,我應該怎麼辦。任何幫助將不勝感激。
您是否在垃圾郵件或垃圾郵件文件夾中檢查了它? –
@Sanjay Kumar N S是的,我也檢查了垃圾郵件和垃圾郵件。 – TeamIncredibles
我懷疑這條消息是通用的,並非特定於你 - 發佈整個SMTP轉錄。你也只需要包含自動加載器,而不是其他類。 – Synchro