0
我需要能夠發送電子郵件到存儲在數據庫(其通訊不是垃圾郵件:P) 聯繫人。我可以使用mail()和循環來做到這一點,但 我讀過這不是一個好主意,因爲可能有幾百個聯繫人。使用郵件()在php中的多個聯繫人
什麼是最好的方式去做這件事?任何意見或指針在 正確的方向將不勝感激!
謝謝。
我需要能夠發送電子郵件到存儲在數據庫(其通訊不是垃圾郵件:P) 聯繫人。我可以使用mail()和循環來做到這一點,但 我讀過這不是一個好主意,因爲可能有幾百個聯繫人。使用郵件()在php中的多個聯繫人
什麼是最好的方式去做這件事?任何意見或指針在 正確的方向將不勝感激!
謝謝。
郵件()將非常緩慢,有數百個聯繫人。我建議swiftmailer在http://www.swiftmailer.org。下面是從thier網站發送郵件很多的例子:
require_once 'lib/swift_required.php';
//Create the Transport
$transport = Swift_SmtpTransport::newInstance('localhost', 25);
//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
$numSent = $mailer->batchSend($message);
而且你可以用你的SMTP連接/帳號發送,或者郵件發送。