Пример #1
0
 /**
  * SMTP接続を開始する。
  *
  * @param
  *
  * @return boolean
  */
 public function openSmtpConnect()
 {
     // 未接続なら接続処理
     if (!$this->smtp_conn) {
         $mailServerIpAry = array();
         // IPが空ならデフォルトセット
         if (!$this->_smtpMailServerIp) {
             // デフォルト(通常)
             $this->setSendMailServerIp(self::DEFAULT_SMTP_SEND_MAIL_IP);
         }
         // ホストとポートに分ける
         $mailServerIpAry = explode(":", $this->_smtpMailServerIp);
         // host
         $host = $mailServerIpAry[0];
         // port
         $port = $mailServerIpAry[1];
         // 接続先をセット
         $this->setSmtpHost($host, (int) $port);
         // 接続
         try {
             // 接続出来なければ、リトライ(指定秒間隔)
             for ($cnt = 0; $cnt < $this->_retrySmtpConnCnt; $cnt++) {
                 // 接続確立
                 if ($this->_openSmtpConn()) {
                     break;
                 }
                 // 10秒インターバル
                 sleep($this->_retrySmtpInterval);
             }
             // それもダメならさよなら。
             if (!$this->getSmtpConnect()) {
                 return false;
             }
             // 接続後、最初に必要なSMTPコマンドをここでやっちゃおう!!
             if (!$this->_sendSmtpCommand("helo " . $this->smtp_host, array(220, 250, 354))) {
                 return false;
             }
         } catch (Zend_Exception $e) {
             // デバッグメール
             $InfoMailOBJ = new InfoMail();
             $debugMail = "";
             $debugMail["subject"] = "SMTP接続エラー";
             $debugMail["text_body"][] = "file:" . __FILE__;
             $debugMail["text_body"][] = "line:" . __LINE__;
             $debugMail["text_body"][] = "err:" . $e->getMessage();
             $debugMail["text_body"][] = "server_ip:" . $this->_smtpMailServerIp;
             $debugMail["text_body"] = implode("\n", $debugMail["text_body"]);
             // システムにエラーメール
             $InfoMailOBJ->debugMailTo($debugMail);
         }
     }
     return true;
 }