2013-03-08 100 views
0

使用php郵件http://php.net/manual/en/function.mail.php如果郵件發送正常,它返回true。php郵件功能和郵件服務器

但是用我的網絡主機發送的速率是3000 /小時,然後服務器將在達到3000限制(這是3000限制的15%)之後存儲450封電子郵件。

我想確認的是,當PHP郵件函數返回true時,它應付這些設置。郵件服務器確認郵件功能是否發送OK或郵件功能是否「盲」?

郵件服務器是否對功能說,限制達到的電子郵件不發送所以返回false?

+2

不使用電子郵件()爲羣發郵件,即使是這樣說的郵件頁面上。 **「值得注意的是,mail()函數並不適用於循環中的大量電子郵件,該函數打開並關閉每個電子郵件的SMTP套接字,效率不高。** – 2013-03-08 02:50:20

+0

郵件不太可能是被主機排隊等候的可能性更大,只有主持人可以證實這一點,特別是如果你不知道你在做什麼,請特別注意發送大量電子郵件,特別是在共享主機上。 – 2013-03-08 02:51:51

+0

郵件功能只有在接受郵件發送時纔會返回true,但是它不知道發生了什麼後會發生什麼,就像文檔狀態一樣,「重要的是要注意,僅僅因爲郵件被接受發送,它並不意味着郵件將實際到達預定目的地。「 – j08691 2013-03-08 02:52:00

回答

1

使用PHP自帶的mail()函數不是最佳解決方案。使用swiftmailer作爲SMTP服務時的代碼

例:使用SWIFTMAILER http://swiftmailer.org/這將作爲SMTP服務使用

require_once 'lib/swift_required.php'; 

// Create the Transport 
$transport = Swift_SmtpTransport::newInstance('smtp.example.org', 25) 
    ->setUsername('your username') 
    ->setPassword('your password') 
    ; 

/* 
You could alternatively use a different transport such as Sendmail or Mail: 

// Sendmail 
$transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs'); 

// Mail 
$transport = Swift_MailTransport::newInstance(); 
*/ 

// Create the Mailer using your created Transport 
$mailer = Swift_Mailer::newInstance($transport); 

// Create a message 
$message = Swift_Message::newInstance('Wonderful Subject') 
    ->setFrom(array('[email protected]' => 'John Doe')) 
    ->setTo(array('[email protected]', '[email protected]' => 'A name')) 
    ->setBody('Here is the message itself') 
    ; 

// Send the message 
$result = $mailer->send($message);