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