我創建了一個會員只能爲基礎的網站,當我發表新文章,(類似博客文章),我使用的PHPMailer發送電子郵件給所有所請求的電子郵件到成員被髮送給他們。進度條/ PHPMailer的電子郵件中發送animated.gif
電子郵件包含新的文章內容。標題,描述等。
我在beta測試階段是,現在,只有3個電子郵件帳戶需要花費大約9秒的時候我做了一個新帖子發出3個電子郵件。每封郵件約3秒鐘。
我希望得到這個網站,就=約5分鐘發出所有這些郵件圍繞100個用戶。
問題
有沒有辦法在發送郵件時,我可以掛鉤實時進度條來顯示多少時間還剩下什麼?
我的設置是這樣的:
我有我的形式連接到這個動作腳本。
<?php
include($_SERVER['DOCUMENT_ROOT'] . "/core/init.php");
// new data
$title = $_POST['title'];
$description = $_POST['description'];
// query
$addnotice = DB::getInstance()->insert('table1', array(
'title' => $title,
'description' => $description,
));
$id = isset($_POST['id']);
$users = DB::getInstance()->query("SELECT id, title, description FROM table1");
$users = DB::getInstance()->query("SELECT email FROM table2 WHERE notify= 'Yes'");
foreach($users->results() as $u){
User::sendNotification($u->email, $title, '<strong><h2>'.$title.'</h2></strong><p>'.$description.'</p>');
}
Session::flash('newarticle', '<h3 class="white-tx" align="center">The article has been added!</h3>');
Redirect::to('sitepage.php');
?>
的User::sendNotification
來自我的用戶類文件看起來像這樣。
public function sendNotification($to, $subject, $body) {
require_once 'class.phpmailer.php';
$from = "[email protected]*******.com";
$mail = new PHPMailer();
$mail->IsSMTP(true); // use SMTP
$mail->IsHTML(true);
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "host***.*******.com"; // SMTP host
$mail->Port = 465; // set the SMTP port
$mail->Username = "[email protected]******.com"; // SMTP username
$mail->Password = "********"; // SMTP password
$mail->SetFrom($from, 'Email Robot');
$mail->AddReplyTo($from,'Do Not Reply');
$mail->Subject = $subject;
$mail->MsgHTML($body);
$address = $to;
$mail->AddAddress($address, $to);
$mail->Send();
}
實時進度條將是理想的,但我甚至會解決一個動畫.gif加載圖像。
其中我試圖通過增加這動作腳本:
echo '<table align="center" width="100%" height="100%" border="0"><tr align="center" valign="center"><td><img src="images/sending.gif"></td></tr></table>';
但是,甚至沒有被認可和右滾過去sending.gif圖像並張貼文章的網站和發送電子郵件。
我搜索谷歌關於這一主題的教程,但來到了幹。
在這種情況下,任何想法,將不勝感激。
「我已經搜索谷歌關於這一主題的教程,但來到了幹。」在搜索中添加「jquery」。 – developerwjk
這不是你想要做到的。使用[Swiftmailer](http://swiftmailer.org/),將郵件存儲在隊列中,並從cron作業異步發送(例如,每隔5分鐘)。 – nietonfir
如果郵件不是個性化的,您可以向BCC中列出的每個收件人發送1封電子郵件。 – Pixelchemist