Beispiel #1
0
function tiki_mail_setup()
{
    static $done = false;
    if ($done) {
        return;
    }
    global $prefs;
    if ($prefs['zend_mail_handler'] == 'smtp') {
        $options = array();
        if ($prefs['zend_mail_smtp_auth']) {
            $options['auth'] = $prefs['zend_mail_smtp_auth'];
            $options['username'] = $prefs['zend_mail_smtp_user'];
            $options['password'] = $prefs['zend_mail_smtp_pass'];
        }
        if ($prefs['zend_mail_smtp_port']) {
            $options['port'] = $prefs['zend_mail_smtp_port'];
        }
        if ($prefs['zend_mail_smtp_security']) {
            $options['ssl'] = $prefs['zend_mail_smtp_security'];
        }
        // hollmeer 2012-11-03: ADDED PGP/MIME ENCRYPTION PREPARATION
        if ($prefs['openpgp_gpg_pgpmimemail'] == 'y') {
            // USE PGP/MIME MAIL VERSION
            $transport = new OpenPGP_Zend_Mail_Transport_Smtp($prefs['zend_mail_smtp_server'], $options);
            OpenPGP_Zend_Mail::setDefaultTransport($transport);
        } else {
            // USE ORIGINAL TIKI MAIL VERSION
            $transport = new Zend_Mail_Transport_Smtp($prefs['zend_mail_smtp_server'], $options);
            Zend_Mail::setDefaultTransport($transport);
        }
    } elseif ($prefs['zend_mail_handler'] == 'file') {
        $transport = new Zend_Mail_Transport_File(array('path' => 'temp', 'callback' => function ($transport) {
            return 'Mail_' . date('YmdHis') . '_' . mt_rand() . '.tmp';
        }));
        Zend_Mail::setDefaultTransport($transport);
    } elseif ($prefs['zend_mail_handler'] == 'sendmail' && !empty($prefs['sender_email'])) {
        // from http://framework.zend.com/manual/1.12/en/zend.mail.introduction.html#zend.mail.introduction.sendmail
        $transport = new Zend_Mail_Transport_Sendmail('-f' . $prefs['sender_email']);
        Zend_Mail::setDefaultTransport($transport);
    }
    $done = true;
}
 /**
  * Send a mail using this transport
  *
  * @param  OpenPGP_Zend_Mail $mail
  * @access public
  * @return void
  * @throws Zend_Mail_Transport_Exception if mail is empty
  */
 public function send(OpenPGP_Zend_Mail $mail)
 {
     $this->_isMultipart = false;
     $this->_mail = $mail;
     $this->_parts = $mail->getParts();
     $mime = $mail->getMime();
     // Build body content
     $this->_buildBody();
     // Determine number of parts and boundary
     $count = count($this->_parts);
     $boundary = null;
     if ($count < 1) {
         throw new Zend_Mail_Transport_Exception('Empty mail cannot be sent');
     }
     if ($count > 1) {
         // Multipart message; create new MIME object and boundary
         $mime = new Zend_Mime($this->_mail->getMimeBoundary());
         $boundary = $mime->boundary();
     } elseif ($this->_isMultipart) {
         // multipart/alternative -- grab boundary
         $boundary = $this->_parts[0]->boundary;
     }
     // Determine recipients, and prepare headers
     $this->recipients = implode(',', $mail->getRecipients());
     $this->_prepareHeaders($this->_getHeaders($boundary));
     // Create message body
     // This is done so that the same OpenPGP_Zend_Mail object can be used in
     // multiple transports
     $message = new Zend_Mime_Message();
     $message->setParts($this->_parts);
     $message->setMime($mime);
     $this->body = $message->generateMessage($this->EOL);
     ////////////////////////////////////////////////////////
     //                                                    //
     // ALPHAFIELDS 2012-11-03: ADDED PGP/MIME ENCRYPTION  //
     // USING lib/openpgp/opepgplib.php                    //
     //                                                    //
     ////////////////////////////////////////////////////////
     // get from globals (set in tiki-setup.php)
     global $openpgplib;
     $pgpmime_msg = $openpgplib->prepareEncryptWithZendMail($this->header, $this->body, $mail->getRecipients());
     $this->header = $pgpmime_msg[0];
     // set pgp/mime headers from result array
     $this->body = $pgpmime_msg[1];
     // set pgp/mime encrypted message body from result array
     ////////////////////////////////////////////////////////
     //                                                    //
     // ALPHAFIELDS 2012-11-03: ..END PGP/MIME ENCRYPTION  //
     //                                                    //
     ////////////////////////////////////////////////////////
     // Send to transport!
     $this->_sendMail();
 }
 /**
  * Clears the default ReplyTo-address and -name from the mail
  *
  * @return void
  */
 public static function clearDefaultReplyTo()
 {
     self::$_defaultReplyTo = null;
 }