예제 #1
0
 /**
  * Send an email via the SMTP connection protocol
  *
  * Overloaded from method in Zend_Mail_Transport_Smtp so that
  * if the mail is a Zend_Mail_Merge instance, the message is
  * sent using the PowerMTA XMRG method by using a Zend_Mail_Merge
  * object instead of a Zend_Mail object.
  *
  * @return void
  */
 public function _sendMail()
 {
     if (!$this->_mail instanceof PowerMta_Mail_Merge) {
         // not a merge message, so just send normally
         return parent::_sendMail();
     }
     // If sending multiple messages per session use existing adapter
     if (!$this->_connection instanceof PowerMta_Mail_Protocol) {
         // Check if authentication is required and determine required class
         $connectionClass = 'PowerMta_Mail_Protocol';
         Zend_Loader::loadClass($connectionClass);
         $this->setConnection(new $connectionClass($this->_host, $this->_port, $this->_config));
         $this->_connection->connect();
         $this->_connection->helo($this->_name);
     } else {
         // Reset connection to ensure reliable transaction
         $this->_connection->rset();
     }
     // first, we need to check whether there are any XPRTs
     // to worry about in the message
     $messagePayload = $this->header . Zend_Mime::LINEEND . $this->getBody();
     $this->_xprts = $this->getXprts($messagePayload);
     // Set mail return path from sender email address.
     // in the parent implementation, this would be the MAIL
     // message, but in this ESMTP protocol, we can use XMRG
     $this->_connection->xmrg($this->_mail->getReturnPath());
     $overallMergeData = $this->getOverallMergeData();
     // Set recipient forward paths
     foreach ($this->_mail->getRecipients() as $recipientAddress => $recipient) {
         $defaultMergeData = array('Name' => $recipient->getName(), 'Subject' => addslashes($this->getMailSubject($recipient)), 'parts' => $this->getPartsForRecipient($recipient));
         $mergeData = array_merge($overallMergeData, $defaultMergeData, $recipient->getMergeData());
         foreach ($this->getXdfnStatements($mergeData) as $lineNumber => $xdfnStatement) {
             $this->_connection->xdfn($xdfnStatement);
         }
         // finally, add the recipient.
         $this->_connection->rcpt($recipient->getEmailAddress());
     }
     // Issue XPRT command to client
     $this->_connection->xprts($this->_xprts);
 }
예제 #2
0
 /**
  * Willonly issue sending the mail if #$isMailTextAssemble is set to false
  *
  * @inheritdoc
  */
 public function _sendMail()
 {
     if (!$this->isMailTextAssemble) {
         parent::_sendMail();
     }
 }