From 6233da0fa78ab8c4752c0f5f11cc9c30b7640035 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Fri, 31 Jul 2009 14:04:44 +0200 Subject: [PATCH] Simplify specifying the mailer configuration. --- ansel/img/ecard.php | 3 +-- ansel/lib/Report/mail.php | 3 +-- imp/lib/IMP.php | 1 + imp/lib/Mime/Viewer/Pgp.php | 5 ++++- kronolith/lib/Kronolith.php | 21 +++------------------ kronolith/scripts/agenda.php | 11 ++--------- nag/lib/Nag.php | 3 +-- 7 files changed, 13 insertions(+), 34 deletions(-) diff --git a/ansel/img/ecard.php b/ansel/img/ecard.php index f5fcb8a4f..4e344d1f2 100644 --- a/ansel/img/ecard.php +++ b/ansel/img/ecard.php @@ -84,8 +84,7 @@ case 'send': $alt->setBasePart($alternative); /* Send. */ - list($mail_driver, $mail_params) = Horde::getMailerConfig(); - $result = $alt->send($mail_driver, $mail_params); + $result = $alt->send(Horde::getMailerConfig()); if (is_a($result, 'PEAR_Error')) { $notification->push(sprintf(_("There was an error sending your message: %s"), $result->getMessage()), 'horde.error'); } else { diff --git a/ansel/lib/Report/mail.php b/ansel/lib/Report/mail.php index cf32e9b33..7b1b360a7 100644 --- a/ansel/lib/Report/mail.php +++ b/ansel/lib/Report/mail.php @@ -36,7 +36,6 @@ class Ansel_Report_mail extends Ansel_Report { //FIXME: This address should be configurable $mail->addHeader('Sender', 'horde-problem@' . $conf['report_content']['maildomain']); - list($mail_driver, $mail_params) = Horde::getMailerConfig(); - return $mail->send($mail_driver, $mail_params); + return $mail->send(Horde::getMailerConfig()); } } diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index 5c9a97e79..644e4e6bc 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -837,6 +837,7 @@ class IMP */ static public function folderPref($folder, $append) { + if (!isset($GLOBALS['imp_imap'])) var_dump(debug_backtrace()); $def_ns = $GLOBALS['imp_imap']->defaultNamespace(); $empty_ns = $GLOBALS['imp_imap']->getNamespace(''); diff --git a/imp/lib/Mime/Viewer/Pgp.php b/imp/lib/Mime/Viewer/Pgp.php index fe5fc1f6c..d0aec8e37 100644 --- a/imp/lib/Mime/Viewer/Pgp.php +++ b/imp/lib/Mime/Viewer/Pgp.php @@ -355,13 +355,16 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Driver $icon = Horde::img('alerts/success.png', _("Success"), null, $graphicsdir); $sig_text = $sig_result->message; + $success = true; } catch (Horde_Exception $e) { - $icon = Horde::img('alerts/warning.png', _("Warning"), null, $graphicsdir); + $icon = Horde::img('alerts/error.png', _("Error"), null, $graphicsdir); $sig_text = $e->getMessage(); + $success = false; } $ret[$base_id]['status'][] = array( 'icon' => $icon, + 'success' => $success, 'text' => array( Horde_Text_Filter::filter($sig_text, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::NOHTML)) ) diff --git a/kronolith/lib/Kronolith.php b/kronolith/lib/Kronolith.php index 3d1d38331..11a0eb2c4 100644 --- a/kronolith/lib/Kronolith.php +++ b/kronolith/lib/Kronolith.php @@ -1217,14 +1217,6 @@ class Kronolith $myemail = explode('@', $myemail); $from = Horde_Mime_Address::writeAddress($myemail[0], isset($myemail[1]) ? $myemail[1] : '', $ident->getValue('fullname')); - $mail_driver = $conf['mailer']['type']; - $mail_params = $conf['mailer']['params']; - if ($mail_driver == 'smtp' && $mail_params['auth'] && - empty($mail_params['username'])) { - $mail_params['username'] = Horde_Auth::getAuth(); - $mail_params['password'] = Horde_Auth::getCredential('password'); - } - $share = &$GLOBALS['kronolith_shares']->getShare($event->getCalendar()); foreach ($attendees as $email => $status) { @@ -1312,7 +1304,7 @@ class Kronolith $mail->addMimePart($ics); try { - $mail->send($mail_driver, $mail_params); + $mail->send(Horde::getMailerConfig()); $notification->push( sprintf(_("The event notification to %s was successfully sent."), $recipient), 'horde.success' @@ -1403,14 +1395,6 @@ class Kronolith return; } - $mail_driver = $conf['mailer']['type']; - $mail_params = $conf['mailer']['params']; - if ($mail_driver == 'smtp' && $mail_params['auth'] && - empty($mail_params['username'])) { - $mail_params['username'] = Horde_Auth::getAuth(); - $mail_params['password'] = Horde_Auth::getCredential('password'); - } - foreach ($addresses as $lang => $twentyFour) { Horde_Nls::setLang($lang); @@ -1446,10 +1430,11 @@ class Kronolith implode(',', $df_recipients), $from, Horde_Nls::getCharset()); + $mail->addHeader('User-Agent', 'Kronolith ' . $GLOBALS['registry']->getVersion()); $mime_mail->setBody($message, Horde_Nls::getCharset(), true); Horde::logMessage(sprintf('Sending event notifications for %s to %s', $event->title, implode(', ', $df_recipients)), __FILE__, __LINE__, PEAR_LOG_DEBUG); try { - $mime_mail->send($mail_driver, $mail_params, false, false); + $mime_mail->send(Horde::getMailerConfig(), false, false); } catch (Horde_Mime_Exception $e) {} } } diff --git a/kronolith/scripts/agenda.php b/kronolith/scripts/agenda.php index 7b8238ca8..ff0da1a11 100755 --- a/kronolith/scripts/agenda.php +++ b/kronolith/scripts/agenda.php @@ -147,15 +147,8 @@ function send_agendas() $email, $GLOBALS['conf']['reminder']['from_addr'], Horde_Nls::getCharset()); + $mime_mail->addHeader('User-Agent', 'Kronolith ' . $registry->getVersion()); - $mail_driver = $GLOBALS['conf']['mailer']['type']; - $mail_params = $GLOBALS['conf']['mailer']['params']; - if ($mail_driver == 'smtp' && $mail_params['auth'] && - empty($mail_params['username'])) { - Horde::logMessage('Agenda Notifications don\'t work with user based SMTP authentication.', - __FILE__, __LINE__, PEAR_LOG_ERR); - return; - } $pad = max(Horde_String::length(_("All day")) + 2, $twentyFour ? 6 : 8); $message = sprintf(_("Your daily agenda for %s"), @@ -177,7 +170,7 @@ function send_agendas() Horde::logMessage(sprintf('Sending daily agenda to %s', $email), __FILE__, __LINE__, PEAR_LOG_DEBUG); try { - $mime_mail->send($mail_driver, $mail_params, false, false); + $mime_mail->send(Horde::getMailerConfig(), false, false); } catch (Horde_Mime_Exception $e) {} } } diff --git a/nag/lib/Nag.php b/nag/lib/Nag.php index 6360f934a..f85a47b93 100644 --- a/nag/lib/Nag.php +++ b/nag/lib/Nag.php @@ -815,7 +815,6 @@ class Nag return; } - list($mail_driver, $mail_params) = Horde::getMailerConfig(); $mail = new Horde_Mime_Mail(); $mail->addHeader('User-Agent', 'Nag ' . $GLOBALS['registry']->getVersion()); $mail->addHeader('Precedence', 'bulk'); @@ -965,7 +964,7 @@ class Nag Horde::logMessage(sprintf('Sending event notifications for %s to %s', $task->name, implode(', ', $df_recipients)), __FILE__, __LINE__, PEAR_LOG_INFO); - $sent = $mail->send($mail_driver, $mail_params); + $sent = $mail->send(Horde::getMailerConfig()); if (is_a($sent, 'PEAR_Error')) { return $sent; } -- 2.11.0