コード例 #1
0
ファイル: Base.php プロジェクト: horde/horde
 /**
  * Queues the user's submitted registration info for later admin approval.
  *
  * @param mixed $info  Reference to array of parameters to be passed
  *                     to hook.
  *
  * @throws Horde_Exception
  * @throws Horde_Mime_Exception
  */
 public function queueSignup(&$info)
 {
     /* @var $conf array */
     /* @var $injector Horde_Injector */
     /* @var $registry Horde_Registry */
     global $conf, $injector, $registry;
     // Perform any preprocessing if requested.
     $this->_preSignup($info);
     // If it's a unique username, go ahead and queue the request.
     $signup = $this->newSignup($info['user_name']);
     if (!empty($info['extra'])) {
         $signup->setData($info['extra']);
     }
     $signup->setData(array_merge($signup->getData(), array('dateReceived' => time(), 'password' => $info['password'])));
     $this->_queueSignup($signup);
     try {
         $injector->getInstance('Horde_Core_Hooks')->callHook('signup_queued', 'horde', array($info['user_name'], $info));
     } catch (Horde_Exception_HookNotSet $e) {
     }
     if (!empty($conf['signup']['email'])) {
         $link = Horde::url($registry->get('webroot', 'horde') . '/admin/signup_confirm.php', true, -1)->setRaw(true)->add(array('u' => $signup->getName(), 'h' => hash_hmac('sha1', $signup->getName(), $conf['secret_key'])));
         $message = sprintf(Horde_Core_Translation::t("A new account for the user \"%s\" has been requested through the signup form."), $signup->getName()) . "\n\n" . Horde_Core_Translation::t("Approve the account:") . "\n" . $link->copy()->add('a', 'approve') . "\n" . Horde_Core_Translation::t("Deny the account:") . "\n" . $link->copy()->add('a', 'deny');
         $mail = new Horde_Mime_Mail(array('body' => $message, 'Subject' => sprintf(Horde_Core_Translation::t("Account signup request for \"%s\""), $signup->getName()), 'To' => $conf['signup']['email'], 'From' => $conf['signup']['email']));
         $mail->send($injector->getInstance('Horde_Mail'));
     }
 }
コード例 #2
0
ファイル: Mailto.php プロジェクト: raz0rsdge/horde
 /**
  * Actually carry out the action.
  */
 public function doAction($form_params, $form_data, $fields)
 {
     global $conf;
     $mail = new Horde_Mime_Mail();
     $mail->addHeader('From', $form_params['from']);
     $mail->addHeader('Subject', $form_params['subject']);
     $mail->addHeader('To', $form_params['to']);
     if (!empty($form_params['cc'])) {
         $mail->addHeader('Cc', $form_params['cc']);
     }
     if (!empty($form_params['bcc'])) {
         $mail->addHeader('Bcc', $form_params['bcc']);
     }
     $body = '';
     foreach ($fields as $field) {
         $value = array_shift($form_data);
         switch ($field['field_type']) {
             case 'file':
             case 'image':
                 if (!empty($value['file'])) {
                     $mail->addAttachment($value['file'], $value['name'], $value['type']);
                 }
                 break;
             default:
                 $body .= $field['field_label'] . ': ' . $this->_formatFormData($value) . "\n";
                 break;
         }
     }
     $mail->setBody($body);
     return $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
 }
コード例 #3
0
ファイル: Mail.php プロジェクト: jubinpatel/horde
 /**
  * Push content to the recipient.
  *
  * @param Horde_Push $content The content element.
  * @param array      $options Additional options.
  *
  * @return NULL
  */
 public function push(Horde_Push $content, $options = array())
 {
     $contents = $content->getContent();
     $types = $content->getMimeTypes();
     $mail = new Horde_Mime_Mail();
     // @todo Append references
     if (isset($types['text/plain'])) {
         $mail->setBody($content->getStringContent($types['text/plain'][0]));
         unset($contents[$types['text/plain'][0]]);
     }
     if (isset($types['text/html'])) {
         $mail->setHtmlBody($content->getStringContent($types['text/html'][0]), 'UTF-8', !isset($types['text/plain']));
         unset($contents[$types['text/html'][0]]);
     }
     foreach ($contents as $part) {
         $mail->addPart($part['mime_type'], $part['content'], 'UTF-8');
     }
     $mail->addRecipients(explode(',', $this->getAcl()));
     $mail->addHeader('subject', $content->getSummary());
     if (!empty($this->_params['from'])) {
         $mail->addHeader('from', $this->_params['from']);
     }
     $mail->addHeader('to', $this->getAcl());
     if (!empty($options['pretend'])) {
         $mock = new Horde_Mail_Transport_Mock();
         $mail->send($mock);
         return sprintf("Would push mail \n\n%s\n\n%s\n to %s.", $mock->sentMessages[0]['header_text'], $mock->sentMessages[0]['body'], $this->getAcl());
     }
     $mail->send($this->_mail);
     return sprintf('Pushed mail to %s.', $this->getAcl());
 }
コード例 #4
0
ファイル: mail.php プロジェクト: jubinpatel/horde
 /**
  * Report
  */
 function report($message, $users = array())
 {
     global $conf;
     if (empty($users)) {
         $to = $conf['report_content']['email'];
     } else {
         // we are sending a report to to the gallery owner, but fall back
         // to the admin in case the user has no email.
         $to = $this->_getUserEmail($users);
         if (empty($to)) {
             $to = $conf['report_content']['email'];
         }
     }
     $mail = new Horde_Mime_Mail(array('body' => $this->getMessage($message), 'Subject' => $this->getTitle(), 'To' => $to, 'Sender' => 'horde-problem@' . $conf['report_content']['maildomain'], 'From' => $this->getUserEmail()));
     return $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
 }
コード例 #5
0
ファイル: Mail.php プロジェクト: raz0rsdge/horde
 /**
  * Notifies about an alarm by e-mail.
  *
  * @param array $alarm  An alarm hash.
  *
  * @throws Horde_Alarm_Exception
  */
 public function notify(array $alarm)
 {
     if (!empty($alarm['internal']['mail']['sent'])) {
         return;
     }
     if (empty($alarm['params']['mail']['email'])) {
         if (empty($alarm['user'])) {
             return;
         }
         $email = $this->_identity->create($alarm['user'])->getDefaultFromAddress(true);
     } else {
         $email = $alarm['params']['mail']['email'];
     }
     try {
         $mail = new Horde_Mime_Mail(array('Subject' => $alarm['title'], 'To' => $email, 'From' => $email, 'Auto-Submitted' => 'auto-generated', 'X-Horde-Alarm' => $alarm['title']));
         if (isset($alarm['params']['mail']['mimepart'])) {
             $mail->setBasePart($alarm['params']['mail']['mimepart']);
         } elseif (empty($alarm['params']['mail']['body'])) {
             $mail->setBody($alarm['text']);
         } else {
             $mail->setBody($alarm['params']['mail']['body']);
         }
         $mail->send($this->_mail);
     } catch (Horde_Mime_Exception $e) {
         throw new Horde_Alarm_Exception($e);
     }
     $alarm['internal']['mail']['sent'] = true;
     $this->alarm->internal($alarm['id'], $alarm['user'], $alarm['internal']);
 }
コード例 #6
0
ファイル: share.php プロジェクト: jubinpatel/horde
/**
 *
 * @global <type> $conf
 * @param <type> $story_part
 * @param <type> $from
 * @param <type> $recipients
 * @param <type> $subject
 * @param <type> $note
 * @return <type>
 */
function _mail($story_part, $from, $recipients, $subject, $note)
{
    throw new Jonah_Exception('Needs refactoring.');
    global $conf;
    /* Create the MIME message. */
    $mail = new Horde_Mime_Mail(array('Subject' => $subject, 'To' => $recipients, 'From' => $from, 'User-Agent' => 'Jonah ' . $GLOBALS['registry']->getVersion()));
    /* If a note has been provided, add it to the message as a text part. */
    if (strlen($note) > 0) {
        $message_note = new MIME_Part('text/plain', null, 'UTF-8');
        $message_note->setContents($message_note->replaceEOL($note));
        $message_note->setDescription(_("Note"));
        $mail->addMIMEPart($message_note);
    }
    /* Get the story as a MIME part and add it to our message. */
    $mail->addMIMEPart($story_part);
    /* Log the pending outbound message. */
    Horde::log(sprintf('<%s> is sending "%s" to (%s)', $from, $subject, $recipients), 'INFO');
    /* Send the message and return the result. */
    return $mail->send(Horde::getMailerConfig());
}
コード例 #7
0
ファイル: mail.php プロジェクト: jubinpatel/horde
 /**
  * Notify user
  *
  * @param mixed  $user        User or array of users to send notification to
  * @param string $subject     Subject of message
  * @param string $body        Body of message
  * @param array  $attachments Attached files
  *
  * @return true on succes, PEAR_Error on failure
  */
 public function notify($user, $subject, $body, $attachments = array())
 {
     if (empty($user)) {
         return true;
     }
     $mail = new Horde_Mime_Mail(array('body' => $body, 'Subject' => $subject, 'From' => $this->_params['from_addr'], 'User-Agent' => 'Folks ' . $GLOBALS['registry']->getVersion(), 'X-Originating-IP' => $_SERVER['REMOTE_ADDR'], 'X-Remote-Browser' => $_SERVER['HTTP_USER_AGENT']));
     foreach ($attachments as $file) {
         if (file_exists($file)) {
             $mail->addAttachment($file, null, null, 'UTF-8');
         }
     }
     if (is_string($user)) {
         $user = array($user);
     }
     foreach ($user as $recipent) {
         $to = $this->_getUserFromAddr($recipent);
         if (empty($to)) {
             continue;
         }
         $mail->addHeader('To', $to, true);
         $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
     }
     return true;
 }
コード例 #8
0
ファイル: Nag.php プロジェクト: DSNS-LAB/Dmail
 /**
  * Sends email notifications that a task has been added, edited, or
  * deleted to users that want such notifications.
  *
  * @param string $action      The event action. One of "add", "edit", or
  *                            "delete".
  * @param Nag_Task $task      The changed task.
  * @param Nag_Task $old_task  The original task if $action is "edit".
  *
  * @throws Nag_Exception
  */
 public static function sendNotification($action, $task, $old_task = null)
 {
     if (!in_array($action, array('add', 'edit', 'delete'))) {
         throw new Nag_Exception('Unknown event action: ' . $action);
     }
     try {
         $share = $GLOBALS['nag_shares']->getShare($task->tasklist);
     } catch (Horde_Share_Exception $e) {
         Horde::log($e->getMessage(), 'ERR');
         throw new Nag_Exception($e);
     }
     $groups = $GLOBALS['injector']->getInstance('Horde_Group');
     $recipients = array();
     $identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create();
     $from = $identity->getDefaultFromAddress(true);
     $owner = $share->get('owner');
     if (strlen($owner)) {
         $recipients[$owner] = self::_notificationPref($owner, 'owner');
     }
     foreach ($share->listUsers(Horde_Perms::READ) as $user) {
         if (empty($recipients[$user])) {
             $recipients[$user] = self::_notificationPref($user, 'read', $task->tasklist);
         }
     }
     foreach ($share->listGroups(Horde_Perms::READ) as $group) {
         try {
             $group_users = $groups->listUsers($group);
         } catch (Horde_Group_Exception $e) {
             Horde::log($e, 'ERR');
             continue;
         }
         foreach ($group_users as $user) {
             if (empty($recipients[$user])) {
                 $recipients[$user] = self::_notificationPref($user, 'read', $task->tasklist);
             }
         }
     }
     $addresses = array();
     foreach ($recipients as $user => $vals) {
         if (!$vals) {
             continue;
         }
         $identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create($user);
         $email = $identity->getValue('from_addr');
         if (strpos($email, '@') === false) {
             continue;
         }
         if (!isset($addresses[$vals['lang']][$vals['tf']][$vals['df']])) {
             $addresses[$vals['lang']][$vals['tf']][$vals['df']] = array();
         }
         $tmp = new Horde_Mail_Rfc822_Address($email);
         $tmp->personal = $identity->getValue('fullname');
         $addresses[$vals['lang']][$vals['tf']][$vals['df']][] = strval($tmp);
     }
     if (!$addresses) {
         return;
     }
     $mail = new Horde_Mime_Mail(array('User-Agent' => 'Nag ' . $GLOBALS['registry']->getVersion(), 'Precedence' => 'bulk', 'Auto-Submitted' => 'auto-generated', 'From' => $from));
     foreach ($addresses as $lang => $twentyFour) {
         $GLOBALS['registry']->setLanguageEnvironment($lang);
         $view_link = Horde::url('view.php', true)->add(array('tasklist' => $task->tasklist, 'task' => $task->id))->setRaw(true);
         switch ($action) {
             case 'add':
                 $subject = _("Task added:");
                 $notification_message = _("You requested to be notified when tasks are added to your task lists.") . "\n\n" . ($task->due ? _("The task \"%s\" has been added to task list \"%s\", with a due date of: %s.") : _("The task \"%s\" has been added to task list \"%s\".")) . "\n" . str_replace('%', '%%', $view_link);
                 break;
             case 'edit':
                 $subject = _("Task modified:");
                 $notification_message = _("You requested to be notified when tasks are edited on your task lists.") . "\n\n" . _("The task \"%s\" has been edited on task list \"%s\".") . "\n" . str_replace('%', '%%', $view_link) . "\n\n" . _("Changes made for this task:");
                 if ($old_task->name != $task->name) {
                     $notification_message .= "\n - " . sprintf(_("Changed name from \"%s\" to \"%s\""), $old_task->name, $task->name);
                 }
                 if ($old_task->tasklist != $task->tasklist) {
                     $old_share = $GLOBALS['nag_shares']->getShare($old_task->tasklist);
                     $notification_message .= "\n - " . sprintf(_("Changed task list from \"%s\" to \"%s\""), Nag::getLabel($old_share), Nag::getLabel($share));
                 }
                 if ($old_task->parent_id != $task->parent_id) {
                     $old_parent = $old_task->getParent();
                     try {
                         $parent = $task->getParent();
                         $notification_message .= "\n - " . sprintf(_("Changed parent task from \"%s\" to \"%s\""), $old_parent ? $old_parent->name : _("no parent"), $parent ? $parent->name : _("no parent"));
                     } catch (Nag_Exception $e) {
                     }
                 }
                 if ($old_task->assignee != $task->assignee) {
                     $identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create($old_task->assignee);
                     $old_name = $identity->getValue('fullname');
                     if (!strlen($old_name)) {
                         $old_name = $old_task->assignee;
                     }
                     $identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create($task->assignee);
                     $new_name = $identity->getValue('fullname');
                     if (!strlen($new_name)) {
                         $new_name = $new_task->assignee;
                     }
                     $notification_message .= "\n - " . sprintf(_("Changed assignee from \"%s\" to \"%s\""), $old_name, $new_name);
                 }
                 if ($old_task->private != $task->private) {
                     $notification_message .= "\n - " . ($task->private ? _("Turned privacy on") : _("Turned privacy off"));
                 }
                 if ($old_task->due != $task->due) {
                     $notification_message .= "\n - " . sprintf(_("Changed due date from %s to %s"), $old_task->due ? self::formatDate($old_task->due) : _("no due date"), $task->due ? self::formatDate($task->due) : _("no due date"));
                 }
                 if ($old_task->start != $task->start) {
                     $notification_message .= "\n - " . sprintf(_("Changed start date from %s to %s"), $old_task->start ? self::formatDate($old_task->start) : _("no start date"), $task->start ? self::formatDate($task->start) : _("no start date"));
                 }
                 if ($old_task->alarm != $task->alarm) {
                     $notification_message .= "\n - " . sprintf(_("Changed alarm from %s to %s"), self::formatAlarm($old_task->alarm), self::formatAlarm($task->alarm));
                 }
                 if ($old_task->priority != $task->priority) {
                     $notification_message .= "\n - " . sprintf(_("Changed priority from %s to %s"), $old_task->priority, $task->priority);
                 }
                 if ($old_task->estimate != $task->estimate) {
                     $notification_message .= "\n - " . sprintf(_("Changed estimate from %s to %s"), $old_task->estimate, $task->estimate);
                 }
                 if ($old_task->completed != $task->completed) {
                     $notification_message .= "\n - " . sprintf(_("Changed completion from %s to %s"), $old_task->completed ? _("completed") : _("not completed"), $task->completed ? _("completed") : _("not completed"));
                 }
                 if ($old_task->desc != $task->desc) {
                     $notification_message .= "\n - " . _("Changed description");
                 }
                 break;
             case 'delete':
                 $subject = _("Task deleted:");
                 $notification_message = _("You requested to be notified when tasks are deleted from your task lists.") . "\n\n" . _("The task \"%s\" has been deleted from task list \"%s\".");
                 break;
         }
         $mail->addHeader('Subject', $subject . ' ' . $task->name);
         foreach ($twentyFour as $tf => $dateFormat) {
             foreach ($dateFormat as $df => $df_recipients) {
                 $message = sprintf($notification_message, $task->name, Nag::getLabel($share), $task->due ? strftime($df, $task->due) . ' ' . date($tf ? 'H:i' : 'h:ia', $task->due) : '');
                 if (strlen(trim($task->desc))) {
                     $message .= "\n\n" . _("Task description:") . "\n\n" . $task->desc;
                 }
                 $mail->setBody($message);
                 $mail->clearRecipients();
                 $mail->addRecipients($df_recipients);
                 Horde::log(sprintf('Sending event notifications for %s to %s', $task->name, implode(', ', $df_recipients)), 'INFO');
                 $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
             }
         }
     }
 }
コード例 #9
0
ファイル: resetpassword.php プロジェクト: jubinpatel/horde
/* Validate the form. */
if ($can_validate && $form->validate($vars)) {
    $form->getInfo($vars, $info);
    /* Fetch values from prefs for selected user. */
    $answer = $prefs->getValue('security_answer');
    /* Check the given values witht the prefs stored ones. */
    if ($email == $info['email'] && strtolower($answer) == strtolower($info['answer'])) {
        /* Info matches, so reset the password. */
        try {
            $password = $auth->resetPassword($info['username']);
            $success = true;
        } catch (Horde_Exception $e) {
            $notification->push($e);
            $success = false;
        }
        $mail = new Horde_Mime_Mail(array('body' => sprintf(_("Your new password for %s is: %s"), $registry->get('name', 'horde'), $password), 'charset' => 'UTF-8', 'From' => empty($conf['auth']['resetpassword_from']) ? $email : $conf['auth']['resetpassword_from'], 'To' => $email, 'Subject' => _("Your password has been reset")));
        try {
            $mail->send($injector->getInstance('Horde_Mail'));
            $notification->push(_("Your password has been reset, check your email and log in with your new password."), 'horde.success');
            $registry->getServiceLink('login')->add('url', $info['url'])->redirect();
            exit;
        } catch (Horde_Exception $e) {
            Horde::log($e, 'ERR');
            $notification->push(_("Your password has been reset, but couldn't be sent to you. Please contact the administrator."), 'horde.error');
        }
    } else {
        /* Info submitted does not match what is in prefs, redirect user back
         * to login. */
        $notification->push(_("Could not reset the password for the requested user. Some or all of the details are not correct. Try again or contact your administrator if you need further help."), 'horde.error');
    }
}
コード例 #10
0
ファイル: Driver.php プロジェクト: raz0rsdge/horde
 /**
  * Sends email notifications to a list of recipients.
  *
  * We do some ugly work in here to make sure that no one gets comments
  * mailed to them that they shouldn't see (because of group permissions).
  *
  * @param array $opts  Option hash with notification information.
  *                     Possible values:
  *                     - ticket:     (Whups_Ticket) A ticket. If not set,
  *                                   this is assumed to be a reminder
  *                                   message.
  *                     - recipients: (array|string) The list of recipients,
  *                                   with user names as keys and user roles
  *                                   as values.
  *                     - subject:    (string) The email subject.
  *                     - view:       (Horde_View) The view object for the
  *                                   message text.
  *                     - template:   (string) The template file for the
  *                                   message text.
  *                     - from:       (string) The email sender.
  *                     - new:        (boolean, optional) Whether the passed
  *                                   ticket was just created.
  */
 public function mail(array $opts)
 {
     global $conf, $registry, $prefs;
     $opts = array_merge(array('ticket' => false, 'new' => false), $opts);
     /* Set up recipients and message headers. */
     $mail = new Horde_Mime_Mail(array('X-Whups-Generated' => 1, 'User-Agent' => 'Whups ' . $registry->getVersion(), 'Precedence' => 'bulk', 'Auto-Submitted' => $opts['ticket'] ? 'auto-replied' : 'auto-generated'));
     $mail_always = null;
     if ($opts['ticket'] && !empty($conf['mail']['always_copy'])) {
         $mail_always = $conf['mail']['always_copy'];
         if (strpos($mail_always, '<@>') !== false) {
             try {
                 $mail_always = str_replace('<@>', $opts['ticket']->get('queue_name'), $mail_always);
             } catch (Whups_Exception $e) {
                 $mail_always = null;
             }
         }
         if ($mail_always && !isset($opts['recipients'][$mail_always])) {
             $opts['recipients'][$mail_always] = 'always';
         }
     }
     if ($opts['ticket'] && ($queue = $this->getQueue($opts['ticket']->get('queue'))) && !empty($queue['email'])) {
         $mail->addHeader('From', $queue['email']);
     } elseif (!empty($conf['mail']['from_addr'])) {
         $mail->addHeader('From', $conf['mail']['from_addr']);
     } else {
         $mail->addHeader('From', Whups::formatUser($opts['from']));
     }
     if (!empty($conf['mail']['return_path'])) {
         $mail->addHeader('Return-Path', $conf['mail']['return_path']);
     }
     if ($opts['ticket']) {
         $opts['subject'] = '[' . $registry->get('name') . ' #' . $opts['ticket']->getId() . '] ' . $opts['subject'];
     }
     $mail->addHeader('Subject', $opts['subject']);
     /* Get our array of comments, sorted in the appropriate order. */
     if ($opts['ticket']) {
         $comments = $this->getHistory($opts['ticket']->getId());
         if ($conf['mail']['commenthistory'] == 'new' && count($comments)) {
             $comments = array_pop($comments);
             $comments = array($comments);
         } elseif ($conf['mail']['commenthistory'] != 'chronological') {
             $comments = array_reverse($comments);
         }
     } else {
         $comments = array();
     }
     /* Don't notify any email address more than once. */
     $seen_email_addresses = array();
     /* Get VFS handle for attachments. */
     if ($opts['ticket']) {
         $vfs = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Vfs')->create();
         try {
             $attachments = Whups::getAttachments($opts['ticket']->getId());
         } catch (Whups_Exception $e) {
             $attachments = array();
             Horde::log($e);
         }
     }
     $from = Whups::getUserAttributes($opts['from']);
     foreach ($opts['recipients'] as $user => $role) {
         /* Make sure to check permissions as a guest for the 'always_copy'
          * address, and as the recipient for all others. */
         $to = $full_name = '';
         if (!empty($mail_always) && $user == $mail_always) {
             $details = null;
             $mycomments = Whups::permissionsFilter($comments, 'comment', Horde_Perms::READ, '');
             $to = $mail_always;
         } else {
             $details = Whups::getUserAttributes($user);
             if (!empty($details['email'])) {
                 $to = Whups::formatUser($details);
                 $mycomments = Whups::permissionsFilter($comments, 'comment', Horde_Perms::READ, $details['user']);
             }
             $full_name = $details['name'];
         }
         /* We may have no recipients due to users excluding themselves
          * from self notifies. */
         if (!$to) {
             continue;
         }
         if ($details && $details['type'] == 'user') {
             $user_prefs = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Prefs')->create('whups', array('user' => $details['user']));
             if (($details['user'] == $registry->getAuth() || !$registry->getAuth()) && $from['type'] == 'user' && $details['user'] == $from['user'] && $user_prefs->getValue('email_others_only')) {
                 continue;
             }
         }
         if ($opts['ticket']) {
             /* Add attachments. */
             $attachmentAdded = false;
             if (empty($GLOBALS['conf']['mail']['link_attach'])) {
                 /* We need to remove all attachments because the attachment
                  * list is potentially limited by permissions. */
                 $mail->clearParts();
                 foreach ($mycomments as $comment) {
                     foreach ($comment['changes'] as $change) {
                         if ($change['type'] != 'attachment') {
                             continue;
                         }
                         foreach ($attachments as $attachment) {
                             if ($attachment['name'] != $change['value']) {
                                 continue;
                             }
                             if (!isset($attachment['part'])) {
                                 $attachment['part'] = new Horde_Mime_Part();
                                 $attachment['part']->setType(Horde_Mime_Magic::filenameToMime($change['value'], false));
                                 $attachment['part']->setDisposition('attachment');
                                 $attachment['part']->setContents($vfs->read(Whups::VFS_ATTACH_PATH . '/' . $opts['ticket']->getId(), $change['value']));
                                 $attachment['part']->setName($change['value']);
                             }
                             $mail->addMimePart($attachment['part']);
                             $attachmentAdded = true;
                             break;
                         }
                     }
                 }
             }
             $formattedComment = $this->formatComments($mycomments, $opts['ticket']->getId());
             if (!$attachmentAdded && !strlen(trim($formattedComment)) && $details && $details['type'] == 'user' && $user_prefs->getValue('email_comments_only')) {
                 continue;
             }
             $opts['view']->comment = $formattedComment;
         }
         $addr_ob = new Horde_Mail_Rfc822_Address($to);
         if ($addr_ob->valid) {
             $bare_address = $addr_ob->bare_address;
             if (!empty($seen_email_addresses[$bare_address])) {
                 continue;
             }
             $seen_email_addresses[$bare_address] = true;
             if (empty($full_name) && !is_null($addr_ob->personal)) {
                 $full_name = $addr_ob->personal;
             }
         }
         // Use email address as fallback.
         if (empty($full_name)) {
             $full_name = $to;
         }
         $opts['view']->full_name = $full_name;
         $opts['view']->role = $role;
         $body = $opts['view']->render($opts['template']);
         if (!strlen(trim($body))) {
             continue;
         }
         $mail->setBody($body);
         $mail->addHeaderOb(Horde_Mime_Headers_MessageId::create());
         if ($opts['ticket']) {
             $message_id = '<whups-' . $opts['ticket']->getId() . '-' . md5($user) . '@' . $conf['server']['name'] . '>';
             if ($opts['new']) {
                 $mail->addHeader('Message-ID', $message_id);
             } else {
                 $mail->addHeader('In-Reply-To', $message_id);
                 $mail->addHeader('References', $message_id);
             }
         }
         $mail->clearRecipients();
         $mail->addHeader('To', $to);
         try {
             $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'), true);
             $entry = sprintf('%s Message sent to %s from "%s"', $_SERVER['REMOTE_ADDR'], $to, $GLOBALS['registry']->getAuth());
             Horde::log($entry, 'INFO');
         } catch (Horde_Mime_Exception $e) {
             Horde::log($e, 'ERR');
         }
     }
 }
コード例 #11
0
ファイル: Nag.php プロジェクト: raz0rsdge/horde
 /**
  * Sends out iTip task notification to the assignee.
  *
  * Can be used to send task invitations, updates, and cancellations.
  *
  * @param Nag_Task $task  The task in question.
  * @param Horde_Notification_Handler $notification
  *        A notification object used to show result status.
  * @param integer $action
  *        The type of notification to send. One of the Nag::ITIP_* values.
  * @param Horde_Date $instance
  *        If cancelling a single instance of a recurring task, the date of
  *        this instance.
  * @param  string $range  The range parameter if this is a recurring event.
  *                        Possible values are self::RANGE_THISANDFUTURE
  */
 public static function sendITipNotifications(Nag_Task $task, Horde_Notification_Handler $notification, $action, Horde_Date $instance = null, $range = null)
 {
     global $injector, $registry, $nag_shares;
     if (!$task->assignee) {
         return;
     }
     $ident = $injector->getInstance('Horde_Core_Factory_Identity')->create($task->creator);
     if (!$ident->getValue('from_addr')) {
         $notification->push(sprintf(_("You do not have an email address configured in your Personal Information Preferences. You must set one %shere%s before event notifications can be sent."), $registry->getServiceLink('prefs', 'kronolith')->add(array('app' => 'horde', 'group' => 'identities'))->link(), '</a>'), 'horde.error', array('content.raw'));
         return;
     }
     // Generate image mime part first and only once, because we
     // need the Content-ID.
     $image = self::getImagePart('big_invitation.png');
     $share = $nag_shares->getShare($task->tasklist);
     $view = new Horde_View(array('templatePath' => NAG_TEMPLATES . '/itip'));
     new Horde_View_Helper_Text($view);
     $view->identity = $ident;
     $view->task = $task;
     $view->imageId = $image->getContentId();
     $email = Nag::getUserEmail($task->assignee);
     if (strpos($email, '@') === false) {
         continue;
     }
     /* Determine all notification-specific strings. */
     $method = 'REQUEST';
     switch ($action) {
         case self::ITIP_CANCEL:
             /* Cancellation. */
             $method = 'CANCEL';
             $filename = 'task-cancellation.ics';
             $view->subject = sprintf(_("Cancelled: %s"), $task->name);
             if (empty($instance)) {
                 $view->header = sprintf(_("%s has cancelled \"%s\"."), $ident->getName(), $task->name);
             } else {
                 $view->header = sprintf(_("%s has cancelled an instance of the recurring \"%s\"."), $ident->getName(), $task->name);
             }
             break;
         case self::ITIP_UPDATE:
             if (!empty($task->organizer) && $task->organizer != Nag::getUserEmail($task->creator)) {
                 // Sending a progress update.
                 $method = 'REPLY';
             } else {
                 $method = 'UPDATE';
             }
         case self::ITIP_REQUEST:
         default:
             if (empty($task->status) || $task->status == self::RESPONSE_NONE) {
                 /* Invitation. */
                 $filename = 'task-invitation.ics';
                 $view->subject = $task->name;
                 $view->header = sprintf(_("%s wishes to make you aware of \"%s\"."), $ident->getName(), $task->name);
             } else {
                 $filename = 'task-update.ics';
                 $view->subject = sprintf(_("Updated: %s."), $task->name);
                 $view->header = sprintf(_("%s wants to notify you about changes of \"%s\"."), $ident->getName(), $task->name);
             }
             break;
     }
     $view->attendees = $email;
     $view->organizer = empty($task->organizer) ? $registry->convertUserName($task->creator, false) : $task->organizer;
     /* Build the iCalendar data */
     $iCal = new Horde_Icalendar();
     $iCal->setAttribute('METHOD', $method);
     $vevent = $task->toiCalendar($iCal);
     $iCal->addComponent($vevent);
     /* text/calendar part */
     $ics = new Horde_Mime_Part();
     $ics->setType('text/calendar');
     $ics->setContents($iCal->exportvCalendar());
     $ics->setName($filename);
     $ics->setContentTypeParameter('METHOD', $method);
     $ics->setCharset('UTF-8');
     $ics->setEOL("\r\n");
     /* application/ics part */
     $ics2 = clone $ics;
     $ics2->setType('application/ics');
     /* multipart/mixed part */
     $multipart = new Horde_Mime_Part();
     $multipart->setType('multipart/mixed');
     $inner = self::buildMimeMessage($view, 'notification', $image);
     $inner->addPart($ics);
     $multipart->addPart($inner);
     $multipart->addPart($ics2);
     $recipient = $method != 'REPLY' ? new Horde_Mail_Rfc822_Address($email) : new Horde_Mail_Rfc822_Address($task->organizer);
     $mail = new Horde_Mime_Mail(array('Subject' => $view->subject, 'To' => $recipient, 'From' => $ident->getDefaultFromAddress(true), 'User-Agent' => 'Nag ' . $registry->getVersion()));
     $mail->setBasePart($multipart);
     try {
         $mail->send($injector->getInstance('Horde_Mail'));
         $notification->push(sprintf(_("The task request notification to %s was successfully sent."), $recipient), 'horde.success');
     } catch (Horde_Mime_Exception $e) {
         $notification->push(sprintf(_("There was an error sending a task request notification to %s: %s"), $recipient, $e->getMessage(), $e->getCode()), 'horde.error');
     }
 }
コード例 #12
0
ファイル: Wicked.php プロジェクト: horde/horde
 /**
  * Mails a notification message after encoding the headers and adding the
  * standard username/time line.
  *
  * @param string $message  The message text to send out.
  * @param array $headers   Additional headers to add to the email.
  */
 public static function mail($message, $headers = array())
 {
     global $conf, $registry;
     /* Make sure there's a place configured to send the email. */
     if (empty($conf['wicked']['notify_address'])) {
         return;
     }
     if ($GLOBALS['registry']->getAuth()) {
         $prefix = $GLOBALS['registry']->getAuth();
     } else {
         $prefix = 'guest [' . $_SERVER['REMOTE_ADDR'] . ']';
     }
     $message = $prefix . '  ' . date('r') . "\n\n" . $message;
     /* In case we don't get a user's email address to send the
      * notification from, what should we fall back to for the From:
      * header? */
     $default_from_addr = !empty($conf['wicked']['guest_address']) ? $conf['wicked']['guest_address'] : $conf['wicked']['notify_address'];
     if ($GLOBALS['registry']->getAuth()) {
         $identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create();
         $from = $identity->getValue('fullname');
         if (empty($from)) {
             $from = $registry->get('name');
         }
         $from_addr = $identity->getValue('from_addr');
         if (empty($from_addr)) {
             $from_addr = $default_from_addr;
         }
     } else {
         $from = $registry->get('name') . ' Guest';
         $from_addr = $default_from_addr;
     }
     $mail = new Horde_Mime_Mail(array('body' => $message, 'To' => $conf['wicked']['notify_address'], 'From' => $from . '<' . $from_addr . '>', 'User-Agent' => 'Wicked ' . $GLOBALS['registry']->getVersion(), 'Precedence' => 'bulk', 'Auto-Submitted' => 'auto-replied'));
     foreach (array_keys($headers) as $hkey) {
         $mail->addHeader($hkey, $headers[$hkey]);
     }
     try {
         $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
     } catch (Horde_Mime_Exception $e) {
         $GLOBALS['notification']->push($e);
     }
 }
コード例 #13
0
ファイル: Mail.php プロジェクト: raz0rsdge/horde
 /**
  * Sends a SMART response.
  *
  * @throws Horde_ActiveSync_Exception
  */
 protected function _sendSmart()
 {
     $mime_message = $this->_raw->getMimeObject();
     // Need to remove content-type header from the incoming raw message
     // since in a smart request, we actually construct the full MIME msg
     // ourselves and the content-type in _headers only applies to the reply
     // text sent from the client, not the fully generated MIME message.
     $this->_headers->removeHeader('Content-Type');
     $this->_headers->removeHeader('Content-Transfer-Encoding');
     $mail = new Horde_Mime_Mail($this->_headers->toArray(array('charset' => 'UTF-8')));
     $base_part = $this->imapMessage->getStructure();
     $plain_id = $base_part->findBody('plain');
     $html_id = $base_part->findBody('html');
     try {
         $body_data = $this->imapMessage->getMessageBodyData(array('protocolversion' => $this->_version, 'bodyprefs' => array(Horde_ActiveSync::BODYPREF_TYPE_MIME => true)));
     } catch (Horde_Exception_NotFound $e) {
         throw new Horde_ActiveSync_Exception($e->getMessage());
     }
     if (!empty($html_id)) {
         $mail->setHtmlBody($this->_getHtmlPart($html_id, $mime_message, $body_data, $base_part));
     } elseif (!empty($plain_id)) {
         $mail->setBody($this->_getPlainPart($plain_id, $mime_message, $body_data, $base_part));
     }
     if ($this->_forward) {
         foreach ($base_part->contentTypeMap() as $mid => $type) {
             if ($this->imapMessage->isAttachment($mid, $type)) {
                 $mail->addMimePart($this->imapMessage->getMimePart($mid));
             }
         }
     }
     foreach ($mime_message->contentTypeMap() as $mid => $type) {
         if ($mid != 0 && $mid != $mime_message->findBody('plain') && $mid != $mime_message->findBody('html')) {
             $mail->addMimePart($mime_message->getPart($mid));
         }
     }
     try {
         $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
         $this->_mailer = $mail;
     } catch (Horde_Mime_Exception $e) {
         throw new Horde_ActiveSync_Exception($e);
     }
 }
コード例 #14
0
ファイル: Mail.php プロジェクト: jubinpatel/horde
 /**
  * Sends a SMART request.
  *
  * @throws Horde_ActiveSync_Exception
  */
 protected function _sendSmart()
 {
     $mime_message = $this->_raw->getMimeObject();
     $mail = new Horde_Mime_Mail($this->_headers->toArray(array('charset' => 'UTF-8')));
     $base_part = $this->imapMessage->getStructure();
     $plain_id = $base_part->findBody('plain');
     $html_id = $base_part->findBody('html');
     try {
         $body_data = $this->imapMessage->getMessageBodyData(array('protocolversion' => $this->_version, 'bodyprefs' => array(Horde_ActiveSync::BODYPREF_TYPE_MIME => true)));
     } catch (Horde_Exception_NotFound $e) {
         throw new Horde_ActiveSync_Exception($e->getMessage());
     }
     if (!empty($html_id)) {
         $mail->setHtmlBody($this->_getHtmlPart($html_id, $mime_message, $body_data, $base_part));
     }
     if (!empty($plain_id)) {
         $mail->setBody($this->_getPlainPart($plain_id, $mime_message, $body_data, $base_part));
     }
     if ($this->_forward) {
         foreach ($base_part->contentTypeMap() as $mid => $type) {
             if ($this->imapMessage->isAttachment($mid, $type)) {
                 $mail->addMimePart($this->imapMessage->getMimePart($mid));
             }
         }
     }
     foreach ($mime_message->contentTypeMap() as $mid => $type) {
         if ($mid != 0 && $mid != $mime_message->findBody('plain') && $mid != $mime_message->findBody('html')) {
             $mail->addMimePart($mime_message->getPart($mid));
         }
     }
     try {
         $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
         $this->_mailer = $mail;
     } catch (Horde_Mime_Exception $e) {
         throw new Horde_ActiveSync_Exception($e);
     }
 }
コード例 #15
0
ファイル: Agora.php プロジェクト: raz0rsdge/horde
 /**
  * Send new posts to a distribution email address for a wider audience
  *
  * @param int $message_id  Identifier of message to be distributed
  *
  * @throws Horde_Mime_Exception
  */
 function distribute($message_id)
 {
     global $conf;
     $storage = $GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create();
     $message = $storage->getMessage($message_id);
     $forum = $storage->getForum($message['forum_id']);
     if (empty($forum['forum_distribution_address'])) {
         return;
     }
     $mail = new Horde_Mime_Mail();
     $mail->addHeader('X-Horde-Agora-Post', $message_id);
     $mail->addHeader('From', strpos($message['message_author'], '@') ? $message['message_author'] : $forum['forum_distribution_address']);
     $mail->addHeader('Subject', '[' . $forum['forum_name'] . '] ' . $message['message_subject']);
     $mail->addHeader('To', $forum['forum_distribution_address']);
     $mail->setBody($message['body']);
     $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
 }
コード例 #16
0
ファイル: ecard.php プロジェクト: raz0rsdge/horde
        $img_tag = '<img src="cid:' . $imgpart->setContentID() . '" /><p />';
        $comments = $htmlpart->replaceEOL(Horde_Util::getFormData('ecard_comments'));
        if (!Horde_Util::getFormData('rtemode')) {
            $comments = '<pre>' . htmlspecialchars($comments, ENT_COMPAT, 'UTF-8') . '</pre>';
        }
        $htmlpart->setContents('<html>' . $img_tag . $comments . '</html>');
        $related->setContentTypeParameter('start', $htmlpart->setContentID());
        $related->addPart($htmlpart);
        $related->addPart($imgpart);
        /* Create the multipart/alternative part. */
        $alternative = new Horde_Mime_Part();
        $alternative->setType('multipart/alternative');
        $alternative->addPart($textpart);
        $alternative->addPart($related);
        /* Add them to the mail message */
        $alt = new Horde_Mime_Mail(array('Subject' => _("Ecard - ") . Horde_Util::getFormData('image_desc'), 'To' => $to, 'From' => $from));
        $alt->setBasePart($alternative);
        /* Send. */
        try {
            $alt->send($injector->getInstance('Horde_Mail'));
        } catch (Horde_Mime_Exception $e) {
            $notification->push(sprintf(_("There was an error sending your message: %s"), $e->getMessage()), 'horde.error');
        }
        echo Horde::wrapInlineScript(array('window.close();'));
        exit;
}
$title = sprintf(_("Send Ecard :: %s"), $image->filename);
/* Set up the form object. */
$vars = Horde_Variables::getDefaultVariables();
$vars->set('actionID', 'send');
$vars->set('image_desc', strlen($image->caption) ? $image->caption : $image->filename);
コード例 #17
0
ファイル: Kronolith.php プロジェクト: AsylumCorp/horde
 /**
  * Sends email notifications that a event has been added, edited, or
  * deleted to users that want such notifications.
  *
  * @param Kronolith_Event $event  An event.
  * @param string $action          The event action. One of "add", "edit",
  *                                or "delete".
  *
  * @throws Horde_Mime_Exception
  * @throws Kronolith_Exception
  */
 public static function sendNotification($event, $action)
 {
     global $injector, $prefs, $registry;
     if (!in_array($action, array('add', 'edit', 'delete'))) {
         throw new Kronolith_Exception('Unknown event action: ' . $action);
     }
     // @TODO: Send notifications to the email addresses stored in the
     // resource object?
     if ($event->calendarType == 'resource') {
         return;
     }
     $groups = $injector->getInstance('Horde_Group');
     $calendar = $event->calendar;
     $recipients = array();
     try {
         $share = $injector->getInstance('Kronolith_Shares')->getShare($calendar);
     } catch (Horde_Share_Exception $e) {
         throw new Kronolith_Exception($e);
     }
     $owner = $share->get('owner');
     if ($owner) {
         $recipients[$owner] = self::_notificationPref($owner, 'owner');
     }
     $senderIdentity = $injector->getInstance('Horde_Core_Factory_Identity')->create($event->creator ?: $owner);
     foreach ($share->listUsers(Horde_Perms::READ) as $user) {
         if (empty($recipients[$user])) {
             $recipients[$user] = self::_notificationPref($user, 'read', $calendar);
         }
     }
     foreach ($share->listGroups(Horde_Perms::READ) as $group) {
         try {
             $group_users = $groups->listUsers($group);
         } catch (Horde_Group_Exception $e) {
             Horde::log($e, 'ERR');
             continue;
         }
         foreach ($group_users as $user) {
             if (empty($recipients[$user])) {
                 $recipients[$user] = self::_notificationPref($user, 'read', $calendar);
             }
         }
     }
     $addresses = array();
     foreach ($recipients as $user => $vals) {
         if (!$vals) {
             continue;
         }
         $identity = $injector->getInstance('Horde_Core_Factory_Identity')->create($user);
         $email = $identity->getValue('from_addr');
         if (strpos($email, '@') === false) {
             continue;
         }
         if (!isset($addresses[$vals['lang']][$vals['tf']][$vals['df']])) {
             $addresses[$vals['lang']][$vals['tf']][$vals['df']] = array();
         }
         $tmp = new Horde_Mail_Rfc822_Address($email);
         $tmp->personal = $identity->getValue('fullname');
         $addresses[$vals['lang']][$vals['tf']][$vals['df']][] = strval($tmp);
     }
     if (!$addresses) {
         return;
     }
     $image = self::getImagePart('big_new.png');
     $view = new Horde_View(array('templatePath' => KRONOLITH_TEMPLATES . '/update'));
     $view->event = $event;
     $view->calendar = Kronolith::getLabel($share);
     $view->imageId = $image->getContentId();
     if (!$prefs->isLocked('event_notification')) {
         $view->prefsUrl = Horde::url($registry->getServiceLink('prefs', 'kronolith'), true)->remove(session_name());
     }
     new Horde_View_Helper_Text($view);
     foreach ($addresses as $lang => $twentyFour) {
         $registry->setLanguageEnvironment($lang);
         switch ($action) {
             case 'add':
                 $subject = _("Event added:");
                 break;
             case 'edit':
                 $subject = _("Event edited:");
                 break;
             case 'delete':
                 $subject = _("Event deleted:");
                 break;
         }
         foreach ($twentyFour as $tf => $dateFormat) {
             foreach ($dateFormat as $df => $df_recipients) {
                 $view->header = $subject . ' ' . $event->title;
                 $mail = new Horde_Mime_Mail(array('Subject' => $view->header, 'To' => implode(',', $df_recipients), 'From' => $senderIdentity->getDefaultFromAddress(true), 'User-Agent' => 'Kronolith ' . $registry->getVersion()));
                 $multipart = self::buildMimeMessage($view, 'notification', $image);
                 $mail->setBasePart($multipart);
                 Horde::log(sprintf('Sending event notifications for %s to %s', $event->title, implode(', ', $df_recipients)), 'DEBUG');
                 $mail->send($injector->getInstance('Horde_Mail'));
             }
         }
     }
 }
コード例 #18
0
ファイル: Kronolith.php プロジェクト: jubinpatel/horde
 /**
  * Sends email notifications that a event has been added, edited, or
  * deleted to users that want such notifications.
  *
  * @param Kronolith_Event $event  An event.
  * @param string $action          The event action. One of "add", "edit",
  *                                or "delete".
  *
  * @throws Horde_Mime_Exception
  * @throws Kronolith_Exception
  */
 public static function sendNotification($event, $action)
 {
     global $injector, $registry;
     if (!in_array($action, array('add', 'edit', 'delete'))) {
         throw new Kronolith_Exception('Unknown event action: ' . $action);
     }
     // @TODO: Send notifications to the email addresses stored in the
     // resource object?
     if ($event->calendarType == 'resource') {
         return;
     }
     $groups = $injector->getInstance('Horde_Group');
     $calendar = $event->calendar;
     $recipients = array();
     try {
         $share = $injector->getInstance('Kronolith_Shares')->getShare($calendar);
     } catch (Horde_Share_Exception $e) {
         throw new Kronolith_Exception($e);
     }
     $owner = $share->get('owner');
     if ($owner) {
         $recipients[$owner] = self::_notificationPref($owner, 'owner');
     }
     $senderIdentity = $injector->getInstance('Horde_Core_Factory_Identity')->create($event->creator ?: $owner);
     foreach ($share->listUsers(Horde_Perms::READ) as $user) {
         if (!isset($recipients[$user])) {
             $recipients[$user] = self::_notificationPref($user, 'read', $calendar);
         }
     }
     foreach ($share->listGroups(Horde_Perms::READ) as $group) {
         try {
             $group_users = $groups->listUsers($group);
         } catch (Horde_Group_Exception $e) {
             Horde::log($e, 'ERR');
             continue;
         }
         foreach ($group_users as $user) {
             if (!isset($recipients[$user])) {
                 $recipients[$user] = self::_notificationPref($user, 'read', $calendar);
             }
         }
     }
     $addresses = array();
     foreach ($recipients as $user => $vals) {
         if (!$vals) {
             continue;
         }
         $identity = $injector->getInstance('Horde_Core_Factory_Identity')->create($user);
         $email = $identity->getValue('from_addr');
         if (strpos($email, '@') === false) {
             continue;
         }
         if (!isset($addresses[$vals['lang']][$vals['tf']][$vals['df']])) {
             $addresses[$vals['lang']][$vals['tf']][$vals['df']] = array();
         }
         $tmp = new Horde_Mail_Rfc822_Address($email);
         $tmp->personal = $identity->getValue('fullname');
         $addresses[$vals['lang']][$vals['tf']][$vals['df']][] = strval($tmp);
     }
     if (!$addresses) {
         return;
     }
     foreach ($addresses as $lang => $twentyFour) {
         $registry->setLanguageEnvironment($lang);
         switch ($action) {
             case 'add':
                 $subject = _("Event added:");
                 $notification_message = _("You requested to be notified when events are added to your calendars.") . "\n\n" . _("The event \"%s\" has been added to \"%s\" calendar, which is on %s at %s.");
                 break;
             case 'edit':
                 $subject = _("Event edited:");
                 $notification_message = _("You requested to be notified when events are edited in your calendars.") . "\n\n" . _("The event \"%s\" has been edited on \"%s\" calendar, which is on %s at %s.");
                 break;
             case 'delete':
                 $subject = _("Event deleted:");
                 $notification_message = _("You requested to be notified when events are deleted from your calendars.") . "\n\n" . _("The event \"%s\" has been deleted from \"%s\" calendar, which was on %s at %s.");
                 break;
         }
         foreach ($twentyFour as $tf => $dateFormat) {
             foreach ($dateFormat as $df => $df_recipients) {
                 $message = "\n" . sprintf($notification_message, $event->title, Kronolith::getLabel($share), $event->start->strftime($df), $event->start->strftime($tf ? '%R' : '%I:%M%p')) . "\n\n" . $event->description;
                 $mime_mail = new Horde_Mime_Mail(array('Subject' => $subject . ' ' . $event->title, 'To' => implode(',', $df_recipients), 'From' => $senderIdentity->getDefaultFromAddress(true), 'User-Agent' => 'Kronolith ' . $registry->getVersion(), 'body' => $message));
                 Horde::log(sprintf('Sending event notifications for %s to %s', $event->title, implode(', ', $df_recipients)), 'DEBUG');
                 $mime_mail->send($injector->getInstance('Horde_Mail'));
             }
         }
     }
 }
コード例 #19
0
ファイル: MailTest.php プロジェクト: raz0rsdge/horde
    public function testParsingAndSending()
    {
        $rfc822_in = 'Subject: Test
From: mike@theupstairsroom.com
Content-Type: text/plain;
    charset=us-ascii
Message-Id: <*****@*****.**>
Date: Sat, 17 Mar 2012 13:29:10 -0400
To: =?utf-8?Q?Mich=C3=B1el_Rubinsky?= <*****@*****.**>
Content-Transfer-Encoding: 7bit
Mime-Version: 1.0 (1.0)

Testing 123
--
Mike';
        $headers = Horde_Mime_Headers::parseHeaders($rfc822_in);
        $message_part = Horde_Mime_Part::parseMessage($rfc822_in);
        $this->assertEquals('Michñel Rubinsky <*****@*****.**>', $headers->getValue('To'));
        $mail = new Horde_Mime_Mail();
        $part = $message_part[$message_part->findBody()];
        $body = $part->getContents();
        $this->assertEquals('Testing 123
--
Mike', $body);
        $mail->addHeaders($headers->toArray());
        $dummy = new Horde_Mail_Transport_Mock();
        $mail->send($dummy);
    }
コード例 #20
0
ファイル: Folks.php プロジェクト: jubinpatel/horde
 /**
  * Send email with attachments
  *
  * @param string $from       From address
  * @param string $subject    Subject of message
  * @param string $body       Body of message
  * @param array  $attaches   Path of file to attach
  *
  * @return true on succes, PEAR_Error on failure
  */
 public static function sendMail($to, $subject, $body, $attaches = array())
 {
     $mail = new Horde_Mime_Mail(array('body' => $body, 'Subject' => $subject, 'To' => $to, 'From' => $GLOBALS['conf']['support'], 'User-Agent' => 'Folks ' . $GLOBALS['registry']->getVersion(), 'X-Originating-IP' => $_SERVER['REMOTE_ADDR'], 'X-Remote-Browser' => $_SERVER['HTTP_USER_AGENT']));
     foreach ($attaches as $file) {
         if (file_exists($file)) {
             $mail->addAttachment($file, null, null, 'UTF-8');
         }
     }
     return $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
 }
コード例 #21
0
ファイル: problem.php プロジェクト: jubinpatel/horde
             } catch (Horde_Exception $e) {
                 $notification->push($e);
             }
         }
         $redirect_url->redirect();
     }
     /* Add user's name to the email address if provided. */
     if ($name) {
         $addr_ob = new Horde_Mail_Rfc822_Address($email);
         if (is_null($addr_ob->host)) {
             $addr_ob->host = $conf['problems']['maildomain'];
         }
         $addr_ob->personal = $name;
         $email = $addr_ob->writeAddress(true);
     }
     $mail = new Horde_Mime_Mail(array('body' => $body, 'Subject' => _("[Problem Report]") . ' ' . $subject, 'To' => $conf['problems']['email'], 'From' => $email));
     $mail->addHeader('Sender', 'horde-problem@' . $conf['problems']['maildomain']);
     /* Add attachment. */
     if ($attachment) {
         $mail->addAttachment($attachment['tmp_name'], $attachment['name'], $attachment['type']);
     }
     try {
         $mail->send($injector->getInstance('Horde_Mail'));
         /* Success. */
         Horde::log(sprintf("%s Message sent to %s from %s", $_SERVER['REMOTE_ADDR'], preg_replace('/^.*<([^>]+)>.*$/', '$1', $conf['problems']['email']), preg_replace('/^.*<([^>]+)>.*$/', '$1', $email)), 'INFO');
         /* Return to previous page and exit this script. */
         $redirect_url->redirect();
     } catch (Horde_Exception $e) {
         $notification->push($e);
     }
 }