]> git.pld-linux.org Git - packages/eventum.git/blob - eventum-bounce-notes.patch
- more todo notes
[packages/eventum.git] / eventum-bounce-notes.patch
1 TODO:
2
3
4 02:32:31  lordrashmi> drafts are restricted too
5 02:33:14  lordrashmi> the delete thing will be a problem
6 02:34:25  lordrashmi> we need some way to indicate that a message has been processed
7
8
9 22:55:08  lordrashmi> glen_: Only thing I can think of for that mail issue is a seperate table
10 22:55:14  lordrashmi> and record the message ID in it
11 22:55:17  lordrashmi> and possible the error
12 23:01:52  lordrashmi> eventum_bounce
13 23:02:21  lordrashmi> bon_id, bon_message_id, bon_error
14
15
16 --- include/class.support.php   (working copy)
17 +++ include/class.support.php   2007-04-03 01:53:39.881559822 +0300
18 @@ -461,6 +461,50 @@
19  
20  
21      /**
22 +     * Bounce message to sender.
23 +     *
24 +     * @access  public
25 +     * @param   object  $message parsed message structure.
26 +     * @param   array   array(ERROR_CODE, ERROR_STRING) of error to bounce
27 +     * @return  void
28 +     */
29 +    function bounceMessage($message, $error)
30 +    {
31 +        // open text template
32 +        $tpl = new Template_API;
33 +        $tpl->setTemplate('notifications/bounced_email.tpl.text');
34 +        $tpl->bulkAssign(array(
35 +            'error_code'        => $error[0],
36 +            'error_message'     => $error[1],
37 +            'date'              => $message->date,
38 +            'subject'           => Mime_Helper::fixEncoding($message->subject),
39 +            'from'              => Mime_Helper::fixEncoding($message->fromaddress),
40 +            'to'                => Mime_Helper::fixEncoding($message->toaddress),
41 +            'cc'                => Mime_Helper::fixEncoding(@$message->ccaddress),
42 +        ));
43 +
44 +        $sender_email = Mail_API::getEmailAddress($message->fromaddress);
45 +        $usr_id = User::getUserIDByEmail($sender_email);
46 +        // change the current locale
47 +        if ($usr_id) {
48 +            Language::set(User::getLang($usr_id));
49 +        }
50 +
51 +        $text_message = $tpl->getTemplateContents();
52 +
53 +        // send email (use PEAR's classes)
54 +        $mail = new Mail_API;
55 +        $mail->setTextBody($text_message);
56 +        $setup = $mail->getSMTPSettings();
57 +        $mail->send($setup['from'], $sender_email,
58 +            APP_SHORT_NAME . ': ' . ev_gettext('Postmaster notify: see transcript for details'));
59 +
60 +        if ($usr_id) {
61 +            Language::restore();
62 +        }
63 +    }
64 +
65 +    /**
66       * Method used to get the information about a specific message
67       * from a given mailbox.
68       *
69 @@ -536,10 +580,11 @@
70                      $res = Routing::getMatchingIssueIDs($addresses, 'email');
71                      if ($res != false) {
72                          $return = Routing::route_emails($message);
73 -                        if ($return == true) {
74 +                        if ($return === true) {
75                              Support::deleteMessage($info, $mbox, $num);
76                              return;
77                          }
78 +                        // TODO: handle errors?
79                          return;
80                      }
81                  }
82 @@ -547,10 +592,13 @@
83                      $res = Routing::getMatchingIssueIDs($addresses, 'note');
84                      if ($res != false) {
85                          $return = Routing::route_notes($message);
86 -                        if ($return == true) {
87 -                            Support::deleteMessage($info, $mbox, $num);
88 -                            return;
89 +                        if ($return !== true) {
90 +                            // in case of error, create bounce, but still
91 +                            // delete email not to send bounce in next process :)
92 +                            Support::bounceMessage($email, $return);
93                          }
94 +
95 +                        Support::deleteMessage($info, $mbox, $num);
96                          return;
97                      }
98                  }
99 @@ -558,10 +606,11 @@
100                      $res = Routing::getMatchingIssueIDs($addresses, 'draft');
101                      if ($res != false) {
102                          $return = Routing::route_drafts($message);
103 -                        if ($return == true) {
104 +                        if ($return === true) {
105                              Support::deleteMessage($info, $mbox, $num);
106                              return;
107                          }
108 +                        // TODO: handle errors?
109                          return;
110                      }
111                  }
112 --- templates/notifications/bounced_email.tpl.text      (revision 0)
113 +++ templates/notifications/bounced_email.tpl.text      (revision 0)
114 @@ -0,0 +1,12 @@
115 +----- {t escape=no}Eventum was unable to route your email{/t} -----
116 +{$error_message}
117 +
118 +----- {t escape=no}The original message headers follow{/t} -----
119 +{$original_message}
120 +Date: {$date}
121 +Subject: {$subject}
122 +From: {$from}
123 +To: {$to}
124 +{if $cc!=''}
125 +Cc: {$cc}
126 +{/if}
This page took 0.125517 seconds and 4 git commands to generate.