<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國際加速解決方案。 廣告
                ### 郵件發送原理 ![](https://box.kancloud.cn/45b4d3dd5455ca45a65b1a4c59255f3a_2446x1098.jpeg) 如果使用阿里云郵箱發送文件,郵箱內容先到阿里云服務器,然后阿里云服務器在轉發給新浪服務器,新浪服務器在轉發給用戶。 ### telnet模擬郵件發送 #### 準備工作: 1)2個郵箱,建議用sina和aliyun郵箱 2)確保telnet命令被允許使用 cmd命令行下:使用telnet工具連上某個郵箱服務的smtp服務器,如aliyun(阿里云): telnet smtp.aliyun.com 25 ### 利用phpmailer類實現郵件發送 phpmailer 下載地址:https://github.com/PHPMailer/PHPMailer/ ~~~ //獲取郵件設置信息 $email_host = getConfigValue('email_host'); $email_title = getConfigValue('email_title'); $email_name = getConfigValue('email_name'); $email_user = getConfigValue('email_user'); $email_password = getConfigValue('email_password'); Vendor('PHPMailer.class#phpmailer'); //實例化PHPMailer類,true表示出現錯誤時拋出異常 $mail = new \PHPMailer(); // 使用SMTP try{ $mail->IsSMTP(); $mail->Host = "smtp.aliyun.com"; // SMTP server $mail->SMTPAuth = true; // 服務器需要驗證 $mail->CharSet ="UTF-8"; //設定郵件編碼 $mail->Username = $email_user; //SMTP服務器的用戶帳號 $mail->Password = $email_password; //SMTP服務器的用戶密碼 //$mail->Port = 25; // 設置端口,使用默認就可以 // $mail->SMTPDebug = 1; // 啟用SMTP調試 1 = errors 2 = messages $mail->SetFrom("chenruiqiang@yd-x.com","gather"); //發件人 if (is_array($tomail)){ foreach ($tomail as $m){ $mail->AddAddress("liushuyu@yd-x.com", 'liushuyu'); //收件人 } }else{ $mail->AddAddress($tomail, 'user'); } $mail->Subject = $title; //郵件主題 $mail->AddReplyTo($email_name,$email_title); //收件人回復時回復到此郵箱,可以多次執行該方法 if($file != '' OR $file != NULL){ $rootpath = $_SERVER['DOCUMENT_ROOT']; $filepath = $rootpath.$file; $mail->AddAttachment($filepath,$filename); // 添加附件,并指定名稱 } $mail->Body = $content; //以下是郵件內容相關 $mail->IsHTML(true); //主題是否包含html內容 $mail->Send(); return true; }catch (Exception $e){ return false; } ~~~ ### 為什么需要隊列 我們需要給網站所有用戶發送一封系統通知郵件,假設網站有10000個注冊用戶,發送沒封郵件需要0.1秒,執行一次發送通知操作需要多長時間? 10000 X 0.1 = 1000秒 = 16(分) 使用隊列先到先發送 使用phpcli 模式。 php cli模式不依靠apache ~~~ $count = 0; while(true){ $count ++ ; echo $count.'\r\n'; if($count >= 10){ break; } sleep(3);停止3秒 echo 'done' } ~~~ 1)觸發隊列 exec函數觸發cli模式 exec('php.exe文件絕對路徑 cli_test.php',) 注意:為了能保持在后臺運行,此程序必須將輸出重定向到文件或其它輸出流。否則會導致 PHP 掛起,直至程序執行結束。 ~~~ <?php function execInBackground($cmd) { if (substr(php_uname(), 0, 7) == "Windows"){ pclose(popen("start /B ". $cmd, "r")); } else { exec($cmd . " > /dev/null &"); } } ?> ~~~ ### 在phpcli模式下測試隊列 ~~~ //判斷隊列進程是否在執行 public function testCmd(){ exec("ps aux | grep /hphc.yd-x.com/Public/mysql/quene_recommand.php",$output,$returnvalue); if(count($output) == 3 && $returnvalue == 0){ return true; }else{ echo '0'; return false; } } ~~~ ### Ajax異步觸發隊列 使用jquery Ajax 出發隊列操作
                  <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>

                              哎呀哎呀视频在线观看