我建議SMTP是去,我發現我在垃圾郵件過濾器等方面得到更好的結果與它反正
我首選的方案是使用方法:https://github.com/PHPMailer/PHPMailer
我有內置的輔助功能,使我更容易實現它
**功能 - 文件名:smtp.function **
<?php
//SMTP controller FUNCTION for PHPMailer script
//source of script: https://github.com/PHPMailer/PHPMailer
require ('PHPMailer-master/PHPMailerAutoload.php');
function SMTP
($to, $subject,$html, $text='')
{
//UPDATE SETTINGS TO MATCH PROJECT SETTINGS
$settings = array('host'=>'XXXXXX','username'=>'XXXXXX','password'=>'XXXXXX','fromEmail'=>'XXXXXX', 'fromName'=>'XXXXXX','replyEmail'=>'XXXXXX', 'replyName'=>'XXXXXX');
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = $settings['host']; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $settings['username']; // SMTP username
$mail->Password = $settings['password']; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->From = $settings['fromEmail'];
$mail->FromName = $settings['fromName'];
//$mail->addAddress('[email protected]', 'Joe User'); // Add a recipient
$mail->addAddress($to); // Name is optional
$mail->addReplyTo($settings['replyEmail'], $settings['replyName']);
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $subject;
$mail->Body = $html;
$mail->AltBody = $text;
//WHAT TO DO IF EMAIL SENDS OR NOT
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
else {
echo 'Message has been sent';
}
}
?>
在PHP中調用它
<?php
require('smtp.function');
SMTP('[email protected]',' This is a test of the SMTP class by Alex','<strong>This test</strong> is <a href="http://www.google.co.uk">HTML CODE</a>');
?>
好,可能有其他原因,例如,在本地綁定或任何DNS解析器(這個,如果你有自己的DNS服務託管)或創建域名在'服務器A'上創建了一些電子郵件帳戶,該帳戶的名稱相同。解決辦法是,將「服務器A」上的任何引用移除到域和/或電子郵件帳戶。我不認爲一個簡單的網絡主機可能會導致問題 – rsz
我有一個託管服務的確切問題。本地DNS服務器是爲我的域配置的,但我在其他地方託管DNS。它只有在支持手動從他們的DNS中刪除我的域時纔得到解決。 –
其實我只注意到DirectAdmin有一個函數可以取消選中本地電子郵件服務器並更改使用的MX記錄。也許這樣做會奏效,聽起來就像是這樣。 – Jason