]> git.pld-linux.org Git - packages/eventum.git/blob - eventum-bounce-notes.patch
- when using mail_download eventum should generate itself error bounces
[packages/eventum.git] / eventum-bounce-notes.patch
1 Index: include/class.support.php
2 ===================================================================
3 --- include/class.support.php   (revision 3290)
4 +++ include/class.support.php   (working copy)
5 @@ -456,6 +461,50 @@
6  
7  
8      /**
9 +     * Bounce message to sender.
10 +     *
11 +     * @access  public
12 +     * @param   object  $message parsed message structure.
13 +     * @param   array   array(ERROR_CODE, ERROR_STRING) of error to bounce
14 +     * @return  void
15 +     */
16 +    function BounceEmail($message, $error)
17 +    {
18 +        // open text template
19 +        $tpl = new Template_API;
20 +        $tpl->setTemplate('notifications/bounced_email.tpl.text');
21 +        $tpl->bulkAssign(array(
22 +            'error_code'        => $error[0],
23 +            'error_message'     => $error[1],
24 +            'date'              => $message->date,
25 +            'subject'           => Mime_Helper::fixEncoding($message->subject),
26 +            'from'              => Mime_Helper::fixEncoding($message->fromaddress),
27 +            'to'                => Mime_Helper::fixEncoding($message->toaddress),
28 +            'cc'                => Mime_Helper::fixEncoding(@$message->ccaddress),
29 +        ));
30 +
31 +        $sender_email = Mail_API::getEmailAddress($message->fromaddress);
32 +        $usr_id = User::getUserIDByEmail($sender_email);
33 +        // change the current locale
34 +        if ($usr_id) {
35 +            Language::set(User::getLang($usr_id));
36 +        }
37 +
38 +        $text_message = $tpl->getTemplateContents();
39 +
40 +        // send email (use PEAR's classes)
41 +        $mail = new Mail_API;
42 +        $mail->setTextBody($text_message);
43 +        $setup = $mail->getSMTPSettings();
44 +        $mail->send($setup['from'], $sender_email,
45 +            APP_SHORT_NAME . ': ' . ev_gettext('Postmaster notify: see transcript for details'));
46 +
47 +        if ($usr_id) {
48 +            Language::restore();
49 +        }
50 +    }
51 +
52 +    /**
53       * Method used to get the information about a specific message
54       * from a given mailbox.
55       *
56 @@ -531,10 +580,11 @@
57                      $res = Routing::getMatchingIssueIDs($addresses, 'email');
58                      if ($res != false) {
59                          $return = Routing::route_emails($message);
60 -                        if ($return == true) {
61 +                        if ($return === true) {
62                              Support::deleteMessage($info, $mbox, $num);
63                              return;
64                          }
65 +                        // TODO: handle errors?
66                          return;
67                      }
68                  }
69 @@ -542,10 +592,13 @@
70                      $res = Routing::getMatchingIssueIDs($addresses, 'note');
71                      if ($res != false) {
72                          $return = Routing::route_notes($message);
73 -                        if ($return == true) {
74 +                        if ($return === true) {
75                              Support::deleteMessage($info, $mbox, $num);
76                              return;
77                          }
78 +
79 +                        // create bounce
80 +                        Support::BounceEmail($email, $return);
81                          return;
82                      }
83                  }
84 @@ -553,10 +606,11 @@
85                      $res = Routing::getMatchingIssueIDs($addresses, 'draft');
86                      if ($res != false) {
87                          $return = Routing::route_drafts($message);
88 -                        if ($return == true) {
89 +                        if ($return === true) {
90                              Support::deleteMessage($info, $mbox, $num);
91                              return;
92                          }
93 +                        // TODO: handle errors?
94                          return;
95                      }
96                  }
97 Index: templates/notifications/bounced_email.tpl.text
98 ===================================================================
99 --- templates/notifications/bounced_email.tpl.text      (revision 0)
100 +++ templates/notifications/bounced_email.tpl.text      (revision 0)
101 @@ -0,0 +1,12 @@
102 +----- {t escape=no}Eventum was unable to route your email{/t} -----
103 +{$error_message}
104 +
105 +----- {t escape=no}The original message headers follow{/t} -----
106 +{$original_message}
107 +Date: {$date}
108 +Subject: {$subject}
109 +From: {$from}
110 +To: {$to}
111 +{if $cc!=''}
112 +Cc: {$cc}
113 +{/if}
This page took 0.034982 seconds and 4 git commands to generate.