Esempio n. 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     require_once 'lib/mail/maillib.php';
     global $prefs;
     $logslib = TikiLib::lib('logs');
     tiki_mail_setup();
     $output->writeln('Mail queue processor starting...');
     $messages = \TikiDb::get()->fetchAll('SELECT messageId, message FROM tiki_mail_queue');
     foreach ($messages as $message) {
         $output->writeln('Sending message ' . $message['messageId'] . '...');
         $mail = unserialize($message['message']);
         if ($mail) {
             try {
                 tiki_send_email($mail);
                 $title = 'mail';
             } catch (Zend\Mail\Exception\ExceptionInterface $e) {
                 $title = 'mail error';
             }
             if ($title == 'mail error' || $prefs['log_mail'] == 'y') {
                 foreach ($mail->getTo() as $destination) {
                     $logslib->add_log($title, $destination->getEmail() . '/' . $mail->getSubject());
                 }
                 foreach ($mail->getCc() as $destination) {
                     $logslib->add_log($title, $destination->getEmail() . '/' . $mail->getSubject());
                 }
                 foreach ($mail->getBcc() as $destination) {
                     $logslib->add_log($title, $destination->getEmail() . '/' . $mail->getSubject());
                 }
             }
             if ($title == 'mail error') {
                 $query = 'UPDATE tiki_mail_queue SET attempts = attempts + 1 WHERE messageId = ?';
                 $output->writeln('Failed.');
             } else {
                 $query = 'DELETE FROM tiki_mail_queue WHERE messageId = ?';
                 $output->writeln('Sent.');
             }
             \TikiDb::get()->query($query, array($message['messageId']));
         } else {
             $output->writeln('ERROR: Unable to unserialize the mailer object.');
         }
     }
     $output->writeln('Mail queue processed...');
 }
Esempio n. 2
0
function tiki_send_email($email)
{
    tiki_mail_setup();
    /* @var $tiki_maillib__zend_mail_default_transport Zend\Mail\Transport\TransportInterface */
    global $tiki_maillib__zend_mail_default_transport;
    $tiki_maillib__zend_mail_default_transport->send($email);
}
Esempio n. 3
0
/**
 * @return Zend_Mail
 */
function tiki_get_basic_mail()
{
    tiki_mail_setup();
    // hollmeer 2012-11-03: ADDED PGP/MIME ENCRYPTION PREPARATION
    // USING lib/openpgp/opepgplib.php
    global $prefs;
    if ($prefs['openpgp_gpg_pgpmimemail'] == 'y') {
        // USE PGP/MIME MAIL VERSION
        $mail = new OpenPGP_Zend_Mail('UTF-8');
    } else {
        // USE ORIGINAL TIKI MAIL VERSION
        $mail = new Zend_Mail('UTF-8');
    }
    $mail->addHeader('X-Tiki', 'yes');
    return $mail;
}
Esempio n. 4
0
function tiki_get_basic_mail()
{
    tiki_mail_setup();
    return new Zend_Mail('UTF-8');
}