$mail = new Horde_Mime_Mail($subject, $body, $to, $GLOBALS['conf']['support'], NLS::getCharset());
require_once FOLKS_BASE . '/lib/version.php';
- $mail->addHeader('User-Agent', 'Folks ' . FOLKS_VERSION);
- $mail->addHeader('X-Originating-IP', $_SERVER['REMOTE_ADDR']);
- $mail->addHeader('X-Remote-Browser', $_SERVER['HTTP_USER_AGENT']);
+ try {
+ $mail->addHeader('User-Agent', 'Folks ' . FOLKS_VERSION);
+ $mail->addHeader('X-Originating-IP', $_SERVER['REMOTE_ADDR']);
+ $mail->addHeader('X-Remote-Browser', $_SERVER['HTTP_USER_AGENT']);
+ } catch (Horde_Mime_Exception $e) {}
foreach ($attaches as $file) {
if (file_exists($file)) {
list($mail_driver, $mail_params) = Horde::getMailerConfig();
- return $mail->send($mail_driver, $mail_params);
+ try {
+ return $mail->send($mail_driver, $mail_params);
+ } catch (Horde_Mime_Exception $e) {}
}
/**
$mail = new Horde_Mime_Mail($this->getTitle(), $this->getMessage($message), $to, $this->getUserEmail());
//FIXME: This address should be configurable
- $mail->addHeader('Sender', 'horde-problem@' . $conf['report_content']['maildomain']);
+ try {
+ $mail->addHeader('Sender', 'horde-problem@' . $conf['report_content']['maildomain']);
+ } catch (Horde_Mime_Exception $e) {}
$mail_driver = $conf['mailer']['type'];
$mail_params = $conf['mailer']['params'];
}
}
- return $mail->send($mail_driver, $mail_params);
+ try {
+ return $mail->send($mail_driver, $mail_params);
+ } catch (Horde_Mime_Exception $e) {}
}
-}
\ No newline at end of file
+}
$body2 = sprintf($body, $row[0], $registry->get('name', 'horde'), Folks::getUrlFor('user', $row[0], true, -1));
// Send mail
- $mail = new MIME_Mail($subject, $body2, $row[1], $conf['support'], NLS::getCharset());
- $mail->addHeader('User-Agent', 'Folks' . FOLKS_VERSION);
- $sent = $mail->send($conf['mailer']['type'], $conf['mailer']['params']);
- if ($sent instanceof PEAR_Error) {
- $cli->message($sent, 'cli.warning');
- } else {
+ $mail = new Horde_Mime_Mail($subject, $body2, $row[1], $conf['support'], NLS::getCharset());
+ try {
+ $mail->addHeader('User-Agent', 'Folks' . FOLKS_VERSION);
+ } catch (Horde_Mime_Exception $e) {}
+ try {
+ $mail->send($conf['mailer']['type'], $conf['mailer']['params']);
$cli->message($row[0], 'cli.success');
+ } catch (Horde_Mime_Exception $e) {
+ $cli->message($e, 'cli.warning');
}
// sleep(1);
case 'auto_save_draft':
case 'save_draft':
/* Set up the From address based on the identity. */
- $from = $identity->getFromLine(null, Util::getFormData('from'));
- if (is_a($from, 'PEAR_Error')) {
- $notification->push($from);
+ try {
+ $from = $identity->getFromLine(null, Util::getFormData('from'));
+ } catch (Horde_Exception $e) {
+ $notification->push($e);
break;
}
$header['from'] = $from;
break;
case 'send_message':
- $from = $identity->getFromLine(null, Util::getFormData('from'));
- if (is_a($from, 'PEAR_Error')) {
- $notification->push($from);
+ try {
+ $from = $identity->getFromLine(null, Util::getFormData('from'));
+ } catch (Horde_Exception $e) {
+ $notification->push($e);
break;
}
$header['from'] = $from;
$message .= "\n" . $sig;
}
- $header['from'] = $identity->getFromLine(null, Util::getFormData('from'));
+ try {
+ $header['from'] = $identity->getFromLine(null, Util::getFormData('from'));
+ } catch (Horde_Exception $e) {
+ $header['from'] = '';
+ }
$header['replyto'] = $identity->getValue('replyto_addr');
$header['subject'] = Util::getFormData('subject');
break;
}
- $from = $identity->getFromLine(null, Util::getFormData('from'));
- if (is_a($from, 'PEAR_Error')) {
+ try {
+ $header['from'] = $identity->getFromLine(null, Util::getFormData('from'));
+ } catch (Horde_Exception $e) {
+ $header['from'] = '';
$get_sig = false;
- $notification->push($from);
+ $notification->push($e);
break;
}
- $header['from'] = $from;
$header['replyto'] = $identity->getValue('replyto_addr');
$header['to'] = $imp_ui->getAddressList(Util::getFormData('to'), Util::getFormData('to_list'), Util::getFormData('to_field'), Util::getFormData('to_new'));
}
/* Set up the From address based on the identity. */
- $header['from'] = $identity->getFromLine(null, Util::getFormData('from'));
- if (is_a($header['from'], 'PEAR_Error')) {
+ try {
+ $header['from'] = $identity->getFromLine(null, Util::getFormData('from'));
+ } catch (Horde_Exception $e) {
+ $header['from'] = '';
$get_sig = false;
- $notification->push($header['from']);
+ $notification->push($e);
break;
}
foreach (array('to', 'cc', 'bcc', 'subject') as $val) {
if ($t->get('di_locked')) {
$t->set('help_compose-from', Help::link('imp', 'compose-from'));
$t->set('fromaddr_locked', $prefs->isLocked('from_addr'));
- $t->set('from', htmlspecialchars($identity->getFromLine(null, Util::getFormData('from'))));
+ try {
+ $t->set('from', htmlspecialchars($identity->getFromLine(null, Util::getFormData('from'))));
+ } catch (Horde_Exception $e) {
+ $t->set('from', '');
+ }
if (!$t->get('fromaddr_locked')) {
$t->set('fromaddr_tabindex', ++$tabindex);
}
if (!empty($headers[$k])) {
$addr = $headers[$k];
if ($session) {
- $addr_check = Horde_Mime::encodeAddress($this->formatAddr($addr), $charset, $_SESSION['imp']['maildomain']);
- if (is_a($addr_check, 'PEAR_Error')) {
- throw new IMP_Compose_Exception(sprintf(_("Saving the draft failed. The %s header contains an invalid e-mail address: %s."), $k, $addr_check->getMessage()));
+ try {
+ Horde_Mime::encodeAddress($this->formatAddr($addr), $charset, $_SESSION['imp']['maildomain']);
+ } catch (Horde_Mime_Exception $e) {
+ throw new IMP_Compose_Exception(sprintf(_("Saving the draft failed. The %s header contains an invalid e-mail address: %s."), $k, $e->getMessage()), $e->getCode());
}
}
$draft_headers->addHeader($v, $addr);
global $conf;
/* Properly encode the addresses we're sending to. */
- $email = Horde_Mime::encodeAddress($email, null, $_SESSION['imp']['maildomain']);
- if (is_a($email, 'PEAR_Error')) {
- throw new IMP_Compose_Exception($email);
+ try {
+ $email = Horde_Mime::encodeAddress($email, null, $_SESSION['imp']['maildomain']);
+ } catch (Horde_Mime_Exception $e) {
+ throw new IMP_Compose_Exception($e);
}
/* Validate the recipient addresses. */
- $result = Horde_Mime_Address::parseAddressList($email, array('defserver' => $_SESSION['imp']['maildomain'], 'validate' => true));
- if (empty($result)) {
+ try {
+ $result = Horde_Mime_Address::parseAddressList($email, array('defserver' => $_SESSION['imp']['maildomain'], 'validate' => true));
+ } catch (Horde_Mime_Exception $e) {
return;
}
return;
}
- $r_array = Horde_Mime::encodeAddress($recipients, null, $_SESSION['imp']['maildomain']);
- if (!is_a($r_array, 'PEAR_Error')) {
+ try {
+ $r_array = Horde_Mime::encodeAddress($recipients, null, $_SESSION['imp']['maildomain']);
$r_array = Horde_Mime_Address::parseAddressList($r_array, array('validate' => true));
- }
+ } catch (Horde_Mime_Exception $e) {}
+
if (empty($r_array)) {
$notification->push(_("Could not save recipients."));
return;
continue;
}
- $obs = Horde_Mime_Address::parseAddressList($email);
- if (empty($obs)) {
+ try {
+ $obs = Horde_Mime_Address::parseAddressList($email);
+ } catch (Horde_Mime_Exception $e) {
throw new IMP_Compose_Exception(sprintf(_("Invalid e-mail address: %s."), $email));
}
/* First we'll get a comma seperated list of email addresses
and a comma seperated list of personal names out of $from
(there just might be more than one of each). */
- $addr_list = Horde_Mime_Address::parseAddressList($from);
- if (!empty($addr_list)) {
+ try {
+ $addr_list = Horde_Mime_Address::parseAddressList($from);
+ } catch (Horde_Mime_Exception $e) {
$addr_list = array();
}
*
* @return string A full From: header in the format
* 'Fullname <user@example.com>'.
+ * @throws Horde_Exception
*/
public function getFromLine($ident = null, $from_address = '')
{
$name = $this->getFullname($ident);
}
- if (!empty($address)) {
+ try {
$ob = Horde_Mime_Address::parseAddressList($address, array('defserver' => $_SESSION['imp']['maildomain']));
- }
- if (empty($ob)) {
- $ob['message'] .= ' ' . _("Your From address is not a valid email address. This can be fixed in your Personal Information options page.");
- return $ob;
+ } catch (Horde_Mime_Exception $e) {
+ throw new Horde_Exception (_("Your From address is not a valid email address. This can be fixed in your Personal Information options page."));
}
if (empty($name)) {
if (!is_array($bcc)) {
$bcc = array($bcc);
}
- return Horde_Mime_Address::parseAddressList(implode(', ', $bcc));
+ try {
+ return Horde_Mime_Address::parseAddressList(implode(', ', $bcc));
+ } catch (Horde_Mime_Exception $e) {
+ return array();
+ }
}
}
$addresses = array($addresses);
}
- $addr_list = Horde_Mime_Address::parseAddressList(implode(', ', $addresses));
- if (empty($addr_list)) {
+ try {
+ $addr_list = Horde_Mime_Address::parseAddressList(implode(', ', $addresses));
+ } catch (Horde_Mime_Exception $e) {
return null;
}
require_once 'Horde/Identity.php';
$imp_compose = &IMP_Compose::singleton();
$identity = &Identity::singleton(array('imp', 'imp'));
- $from_line = $identity->getFromLine();
+ try {
+ $from_line = $identity->getFromLine();
+ } catch (Horde_Exception $e) {
+ $from = '';
+ }
}
/* Build the MIME structure. */
} else {
/* Send out the MDN now. */
$mail_driver = IMP_Compose::getMailDriver();
- $result = $mdn->generate(false, $confirmed, 'displayed', $mail_driver['driver'], $mail_driver['params']);
- if (!is_a($result, 'PEAR_Error')) {
+ try {
+ $mdn->generate(false, $confirmed, 'displayed', $mail_driver['driver'], $mail_driver['params']);
IMP_Maillog::log('mdn', $msg_id, 'displayed');
- }
+ } catch (Horde_Mime_Exception $e) {}
if ($GLOBALS['conf']['sentmail']['driver'] != 'none') {
$sentmail = IMP_Sentmail::factory();
$sentmail->log('mdn', '', $return_addr, !is_a($result, 'PEAR_Error'));
$name = empty($newAttendeeParsedPart->personal)
? ''
: $newAttendeeParsedPart->personal;
- $newAttendeeParsedPartNew = Horde_Mime::encodeAddress(
- Horde_Mime_Address::writeAddress($newAttendeeParsedPart->mailbox,
- $newAttendeeParsedPart->host, $name));
- $newAttendeeParsedPartValidated = $parser->parseAddressList(
- $newAttendeeParsedPartNew, '', null, true);
- if (is_a($newAttendeeParsedPartValidated, 'PEAR_Error')) {
- $notification->push($newAttendeeParsedPartValidated,
- 'horde.error');
- } else {
+
+ try {
+ $newAttendeeParsedPartNew = Horde_Mime::encodeAddress(Horde_Mime_Address::writeAddress($newAttendeeParsedPart->mailbox, $newAttendeeParsedPart->host, $name));
+ $newAttendeeParsedPartValidated = $parser->parseAddressList($newAttendeeParsedPartNew, '', null, true);
+
$email = $newAttendeeParsedPart->mailbox . '@'
. $newAttendeeParsedPart->host;
// Avoid overwriting existing attendees with the default
'response' => KRONOLITH_RESPONSE_NONE,
'name' => $name,
);
+ } catch (Horde_Mime_Exception $e) {
+ $notification->push($e, 'horde.error');
}
}
}
$recipient = empty($status['name']) ? $email : Horde_Mime_Address::trimAddress($status['name'] . ' <' . $email . '>');
$mail = new Horde_Mime_Mail($subject, $message, $recipient, $from, NLS::getCharset());
require_once KRONOLITH_BASE . '/lib/version.php';
- $mail->addHeader('User-Agent', 'Kronolith ' . KRONOLITH_VERSION);
+ try {
+ $mail->addHeader('User-Agent', 'Kronolith ' . KRONOLITH_VERSION);
+ } catch (Horde_Mime_Exception $e) {}
$mail->addMimePart($ics);
- $status = $mail->send($mail_driver, $mail_params);
- if (!is_a($status, 'PEAR_Error')) {
+
+ try {
+ $mail->send($mail_driver, $mail_params);
$notification->push(
sprintf(_("The event notification to %s was successfully sent."), $recipient),
'horde.success'
);
- } else {
+ } catch (Horde_Mime_Exception $e) {
$notification->push(
- sprintf(_("There was an error sending an event notification to %s: %s"), $recipient, $status->getMessage()),
+ sprintf(_("There was an error sending an event notification to %s: %s"), $recipient, $e->getMessage(), $e->getCode()),
'horde.error'
);
}
NLS::getCharset());
$mime_mail->setBody($message, NLS::getCharset(), true);
Horde::logMessage(sprintf('Sending event notifications for %s to %s', $event->title, implode(', ', $df_recipients)), __FILE__, __LINE__, PEAR_LOG_DEBUG);
- $sent = $mime_mail->send($mail_driver, $mail_params, false, false);
- if (is_a($sent, 'PEAR_Error')) {
- return $sent;
- }
+ try {
+ $mime_mail->send($mail_driver, $mail_params, false, false);
+ } catch (Horde_Mime_Exception $e) {}
}
}
}
}
$mime_mail->setBody($message, NLS::getCharset(), true);
- $mime_mail->addRecipients($email);
+ try {
+ $mime_mail->addRecipients($email);
+ } catch (Horde_Mime_Exception $e) {}
Horde::logMessage(sprintf('Sending daily agenda to %s', $email),
__FILE__, __LINE__, PEAR_LOG_DEBUG);
- $sent = $mime_mail->send($mail_driver, $mail_params, false, false);
- if (is_a($sent, 'PEAR_Error')) {
- return $sent;
- }
+ try {
+ $mime_mail->send($mail_driver, $mail_params, false, false);
+ } catch (Horde_Mime_Exception $e) {}
}
}
News::getUrlFor('news', $id, true, -1));
$mail = new Horde_Mime_Mail($row['title'], $body, $to, $from, NLS::getCharset());
-$result = $mail->send($conf['mailer']['type'], $conf['mailer']['params']);
-if ($result instanceof PEAR_Error) {
- $notification->push($result);
-} else {
+try {
+ $mail->send($conf['mailer']['type'], $conf['mailer']['params']);
$notification->push(sprintf(_("News succesfully send to %s"), $to), 'horde.success');
+} catch (Horde_Mime_Exception $e) {
+ $notification->push($e);
}
header('Location: ' . News::getUrlFor('news', $id));
-exit;
\ No newline at end of file
+exit;