<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ###**1. 建表存儲需要發送的郵件** ```sql CREATE TABLE `task_list` ( `task_id` int(5) NOT NULL AUTO_INCREMENT, `user_email` varchar(40) NOT NULL, `status` int(2) NOT NULL, `create_time` datetime NOT NULL, `update_time` datetime NOT NULL, PRIMARY KEY (`task_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; INSERT INTO `muke`.`task_list` (`task_id`, `user_email`, `status`, `create_time`, `update_time`) VALUES ('1', '*******@qq.com', '0', '2017-03-06 10:53:41', '2017-03-06 10:53:41'); ``` ###**2. 使用php+mysql輪詢實現隊列** ``` $rootPath = dirname(__FILE__); require $rootPath.'/PHPMailer/PHPMailerAutoload.php'; function sendMail($host, $fromEmail, $fromPwd, $fromName, $toEmail, $toName, $subject, $content) { $mail = new PHPMailer; $mail->isSMTP(); // 設置郵件使用SMTP $mail->Host = $host; // 郵件服務器地址 $mail->SMTPAuth = true; // 啟用SMTP身份驗證 $mail->CharSet = 'UTF-8'; // 設置郵件編碼 $mail->Encoding = 'base64'; // 使用base64加密郵箱和密碼 $mail->Username = $fromEmail; // SMTP 用戶名,即個人的郵箱地址 $mail->Password = $fromPwd; // SMTP 密碼,即個人的郵箱密碼 $mail->From = $fromEmail; // 發件人郵箱地址 $mail->FromName = $fromName; // 發件人名稱 $mail->addAddress($toEmail, $toName); // 添加接受者 $mail->isHTML(true); // 設置郵件格式為HTML $mail->Subject = $subject; $mail->msgHTML($content); return $mail->send(); } $link = mysql_connect('192.168.2.110', 'root', 'root'); mysql_select_db('muke'); mysql_query("set names utf8"); while (true) { $sql = 'select * from task_list where status=0 order by task_id asc limit 5'; $res = mysql_query($sql); $mailList = array(); while ($row = mysql_fetch_assoc($res)) { $mailList[] = $row; } if(empty($mailList)) { break; } else { foreach ($mailList as $key => $value) { if (sendMail("smtp.aliyun.com", '*****@aliyun.com', '******', 'aliyun', $value['user_email'], 'vision', '模擬隊列發送郵件', file_get_contents($rootPath.'/sendmail.html'))) { mysql_query('update task_list set status=1 where task_id='.$value['task_id']); echo $value['user_email']."\n"; } sleep(3); } } } echo "done\n"; ``` ###**3. 在cli模式下測試隊列** ``` /user/bin/php /var/www/sendmail/queue.php ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看