Mercurial > masqmail
annotate src/deliver.c @ 426:d48d3622b64f
Updated AUTHORS and THANKS files.
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Wed, 30 May 2012 11:49:40 +0200 |
parents | 8fedb93e9b72 |
children | 5593964ec779 |
rev | line source |
---|---|
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
1 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
2 ** MasqMail |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
3 ** Copyright (C) 1999-2002 Oliver Kurth |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
4 ** Copyright (C) 2008, 2010 markus schnalke <meillo@marmaro.de> |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
5 ** |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
6 ** This program is free software; you can redistribute it and/or modify |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
7 ** it under the terms of the GNU General Public License as published by |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
8 ** the Free Software Foundation; either version 2 of the License, or |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
9 ** (at your option) any later version. |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
10 ** |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
11 ** This program is distributed in the hope that it will be useful, |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
14 ** GNU General Public License for more details. |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
15 ** |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
16 ** You should have received a copy of the GNU General Public License |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
17 ** along with this program; if not, write to the Free Software |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
18 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
0 | 19 */ |
20 | |
21 #include <fnmatch.h> | |
22 #include <sysexits.h> | |
23 #include <netdb.h> | |
24 | |
15 | 25 #include "masqmail.h" |
26 #include "smtp_out.h" | |
27 | |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
28 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
29 ** collect failed/defered rcpts for failure/warning messages |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
30 ** returns TRUE if either there are no failures or a failure message has |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
31 ** been successfully sent |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
32 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
33 gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
34 delivery_failures(message *msg, GList *rcpt_list, gchar *err_fmt, ...) |
0 | 35 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
36 gboolean ok_fail = TRUE, ok_warn = TRUE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
37 time_t now = time(NULL); |
0 | 38 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
39 GList *failed_list = NULL, *defered_list = NULL, *rcpt_node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
40 va_list args; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
41 va_start(args, err_fmt); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
42 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
43 foreach(rcpt_list, rcpt_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
44 address *rcpt = (address *) (rcpt_node->data); |
0 | 45 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
46 if (addr_is_defered(rcpt)) { |
403 | 47 if ((now - msg->received_time) >= conf.max_defer_time){ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
48 addr_mark_failed(rcpt); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
49 } else { |
403 | 50 defered_list = g_list_prepend(defered_list, |
51 rcpt); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
52 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
53 } |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
54 if (addr_is_failed(rcpt)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
55 failed_list = g_list_prepend(failed_list, rcpt); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
56 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
57 } |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
58 if (failed_list) { |
403 | 59 ok_fail = fail_msg(msg, conf.errmsg_file, failed_list, |
60 err_fmt, args); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
61 g_list_free(failed_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
62 } |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
63 if (defered_list) { |
403 | 64 ok_warn = warn_msg(msg, conf.warnmsg_file, defered_list, |
65 err_fmt, args); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
66 g_list_free(defered_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
67 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
68 va_end(args); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
69 return ok_fail && ok_warn; |
0 | 70 } |
71 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
72 static gint |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
73 _g_list_strcasecmp(gconstpointer a, gconstpointer b) |
0 | 74 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
75 return (gint) strcasecmp(a, b); |
0 | 76 } |
77 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
78 gboolean |
403 | 79 deliver_local_mbox(message *msg, GList *hdr_list, address *rcpt, |
80 address *env_addr) | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
81 { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
82 DEBUG(1) debugf("attempting to deliver %s with mbox\n", msg->uid); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
83 if (append_file(msg, hdr_list, rcpt->local_part)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
84 if (env_addr != rcpt) { |
403 | 85 logwrite(LOG_NOTICE, "%s => %s@%s <%s@%s> with mbox\n", |
86 msg->uid, rcpt->local_part, | |
87 rcpt->domain, env_addr->local_part, | |
88 env_addr->domain); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
89 } else { |
403 | 90 logwrite(LOG_NOTICE, "%s => <%s@%s> with mbox\n", |
91 msg->uid, rcpt->local_part, | |
92 rcpt->domain); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
93 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
94 addr_mark_delivered(rcpt); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
95 return TRUE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
96 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
97 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
98 /* prevents 'Resource temporarily unavailable (11)' */ |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
99 if (errno != EAGAIN) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
100 addr_mark_failed(rcpt); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
101 } else { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
102 addr_mark_defered(rcpt); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
103 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
104 return FALSE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
105 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
106 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
107 gboolean |
403 | 108 deliver_local_pipe(message *msg, GList *hdr_list, address *rcpt, |
109 address *env_addr) | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
110 { |
403 | 111 guint flags = 0; |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
112 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
113 DEBUG(1) debugf("attempting to deliver %s with pipe\n", msg->uid); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
114 |
403 | 115 flags |= (conf.pipe_fromline) ? MSGSTR_FROMLINE : 0; |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
116 flags |= (conf.pipe_fromhack) ? MSGSTR_FROMHACK : 0; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
117 if (pipe_out(msg, hdr_list, rcpt, &(rcpt->local_part[1]), flags)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
118 logwrite(LOG_NOTICE, "%s => %s <%s@%s> with pipe\n", |
403 | 119 msg->uid, rcpt->local_part, |
120 env_addr->local_part, env_addr->domain); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
121 addr_mark_delivered(rcpt); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
122 return TRUE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
123 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
124 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
125 if ((errno != (1024 + EX_TEMPFAIL)) && (errno != EAGAIN)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
126 addr_mark_failed(rcpt); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
127 } else { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
128 addr_mark_defered(rcpt); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
129 /* has no effect yet, except that mail remains in spool */ |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
130 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
131 return FALSE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
132 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
133 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
134 gboolean |
403 | 135 deliver_local_mda(message *msg, GList *hdr_list, address *rcpt, |
136 address *env_addr) | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
137 { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
138 gboolean ok = FALSE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
139 gchar *cmd = g_malloc(256); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
140 GList *var_table = var_table_rcpt(var_table_msg(NULL, msg), rcpt); |
403 | 141 guint flags = 0; |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
142 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
143 DEBUG(1) debugf("attempting to deliver %s with mda\n", msg->uid); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
144 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
145 if (!expand(var_table, conf.mda, cmd, 256)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
146 logwrite(LOG_ALERT, "could not expand string %s\n", conf.mda); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
147 destroy_table(var_table); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
148 return FALSE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
149 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
150 |
403 | 151 flags |= (conf.mda_fromline) ? MSGSTR_FROMLINE : 0; |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
152 flags |= (conf.mda_fromhack) ? MSGSTR_FROMHACK : 0; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
153 if (pipe_out(msg, hdr_list, rcpt, cmd, flags)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
154 logwrite(LOG_NOTICE, "%s => %s@%s with mda (cmd = '%s')\n", |
403 | 155 msg->uid, rcpt->local_part, rcpt->domain, cmd); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
156 addr_mark_delivered(rcpt); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
157 ok = TRUE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
158 } else if ((errno != (1024 + EX_TEMPFAIL)) && (errno != EAGAIN)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
159 addr_mark_failed(rcpt); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
160 } else { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
161 addr_mark_defered(rcpt); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
162 /* has no effect yet, except that mail remains in spool */ |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
163 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
164 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
165 destroy_table(var_table); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
166 return ok; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
167 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
168 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
169 gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
170 deliver_local(msg_out *msgout) |
0 | 171 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
172 message *msg = msgout->msg; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
173 GList *rcpt_list = msgout->rcpt_list; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
174 GList *rcpt_node; |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
175 gboolean ok = FALSE, flag = FALSE, ok_fail = FALSE; |
0 | 176 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
177 DEBUG(5) debugf("deliver_local entered\n"); |
0 | 178 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
179 flag = (msg->data_list == NULL); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
180 if (flag && !spool_read_data(msg)) { |
403 | 181 logwrite(LOG_ALERT, "could not open data spool file for %s\n", |
182 msg->uid); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
183 return FALSE; |
0 | 184 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
185 |
403 | 186 for (rcpt_node = g_list_first(rcpt_list); rcpt_node; |
187 rcpt_node = g_list_next(rcpt_node)) { | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
188 GList *hdr_list; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
189 address *rcpt = (address *) (rcpt_node->data); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
190 address *env_addr = addr_find_ancestor(rcpt); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
191 address *ret_path = msg->return_path; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
192 header *retpath_hdr, *envto_hdr; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
193 |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
194 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
195 ** we need a private copy of the hdr list because we add |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
196 ** headers here that belong to the rcpt only. g_list_copy |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
197 ** copies only the nodes, so it is safe to g_list_free it |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
198 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
199 hdr_list = g_list_copy(msg->hdr_list); |
403 | 200 retpath_hdr = create_header(HEAD_ENVELOPE_TO, |
201 "Envelope-to: %s\n", addr_string(env_addr)); | |
202 envto_hdr = create_header(HEAD_RETURN_PATH, | |
203 "Return-path: %s\n", addr_string(ret_path)); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
204 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
205 hdr_list = g_list_prepend(hdr_list, envto_hdr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
206 hdr_list = g_list_prepend(hdr_list, retpath_hdr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
207 |
403 | 208 if (*rcpt->local_part == '|') { |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
209 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
210 ** probably for expanded aliases, but why not done |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
211 ** like with the mda? //meillo 2010-12-06 |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
212 */ |
403 | 213 if (deliver_local_pipe(msg, hdr_list, rcpt, |
214 env_addr)) { | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
215 ok = TRUE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
216 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
217 } else { |
403 | 218 /* figure out which mailbox type should be used |
219 ** for this user */ | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
220 gchar *user = rcpt->local_part; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
221 gchar *mbox_type = conf.mbox_default; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
222 |
403 | 223 if (g_list_find_custom(conf.mbox_users, user, |
224 _g_list_strcasecmp)) { | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
225 mbox_type = "mbox"; |
403 | 226 } else if (g_list_find_custom (conf.mda_users, user, |
227 _g_list_strcasecmp)) { | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
228 mbox_type = "mda"; |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
229 } |
0 | 230 |
403 | 231 if (strcmp(mbox_type, "mbox")==0) { |
232 if (deliver_local_mbox(msg, hdr_list, rcpt, | |
233 env_addr)) { | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
234 ok = TRUE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
235 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
236 } else if (strcmp(mbox_type, "mda") == 0) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
237 if (conf.mda) { |
403 | 238 if (deliver_local_mda(msg, hdr_list, |
239 rcpt, env_addr)) { | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
240 ok = TRUE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
241 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
242 } else { |
403 | 243 logwrite(LOG_ALERT, "mbox type is " |
244 "mda, but no mda " | |
245 "command given in " | |
246 "configuration\n"); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
247 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
248 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
249 } else { |
403 | 250 logwrite(LOG_ALERT, "unknown mbox type '%s'\n", |
251 mbox_type); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
252 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
253 } |
0 | 254 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
255 destroy_header(retpath_hdr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
256 destroy_header(envto_hdr); |
0 | 257 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
258 g_list_free(hdr_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
259 } |
403 | 260 ok_fail = delivery_failures(msg, rcpt_list, "%s (%d)", |
261 ext_strerror(errno), errno); | |
0 | 262 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
263 if (flag) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
264 msg_free_data(msg); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
265 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
266 if (ok || ok_fail) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
267 deliver_finish(msgout); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
268 } |
0 | 269 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
270 return ok; |
0 | 271 } |
272 | |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
273 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
274 ** make a list of rcpt's of a message that are local |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
275 ** return a new copy of the list |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
276 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
277 void |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
278 msg_rcptlist_local(GList *rcpt_list, GList **p_local_list, |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
279 GList **p_nonlocal_list) |
0 | 280 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
281 GList *rcpt_node; |
0 | 282 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
283 foreach(rcpt_list, rcpt_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
284 address *rcpt = (address *) (rcpt_node->data); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
285 GList *dom_node; |
0 | 286 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
287 DEBUG(5) debugf("checking address %s\n", rcpt->address); |
0 | 288 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
289 /* search for local host list: */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
290 foreach(conf.local_hosts, dom_node) { |
403 | 291 if (fnmatch(dom_node->data, rcpt->domain, |
292 FNM_CASEFOLD)==0) { | |
293 *p_local_list = g_list_append(*p_local_list, | |
294 rcpt); | |
295 DEBUG(5) debugf("<%s@%s> is local\n", | |
296 rcpt->local_part, | |
297 rcpt->domain); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
298 break; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
299 } else { |
403 | 300 *p_nonlocal_list = g_list_append( |
301 *p_nonlocal_list, rcpt); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
302 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
303 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
304 } |
0 | 305 } |
306 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
307 gboolean |
370 | 308 deliver_msglist_host_pipe(connect_route *route, GList *msgout_list, |
309 gchar *host, GList *res_list) | |
0 | 310 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
311 gboolean ok = TRUE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
312 GList *msgout_node; |
0 | 313 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
314 DEBUG(5) debugf("deliver_msglist_host_pipe entered\n"); |
0 | 315 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
316 foreach(msgout_list, msgout_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
317 msg_out *msgout = (msg_out *) (msgout_node->data); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
318 gboolean flag, ok_fail = FALSE; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
319 message *msg = msgout->msg; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
320 GList *rcpt_node, *rcpt_list = msgout->rcpt_list; |
0 | 321 |
403 | 322 DEBUG(1) debugf("attempting to deliver %s with pipe\n", |
323 msg->uid); | |
0 | 324 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
325 flag = (msg->data_list == NULL); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
326 if (flag && !spool_read_data(msg)) { |
403 | 327 logwrite(LOG_ALERT, "could not open data spool file " |
328 "for %s\n", msg->uid); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
329 continue; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
330 } |
0 | 331 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
332 ok = FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
333 foreach(rcpt_list, rcpt_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
334 address *rcpt = (address *) (rcpt_node->data); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
335 gchar *cmd = g_malloc(256); |
403 | 336 GList *var_table = var_table_rcpt(var_table_msg(NULL, |
337 msg), rcpt); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
338 |
403 | 339 DEBUG(1) debugf("attempting to deliver %s to %s@%s " |
340 "with pipe\n", msg->uid, | |
341 rcpt->local_part, rcpt->domain); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
342 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
343 if (!expand(var_table, route->pipe, cmd, 256)) { |
321 | 344 logwrite(LOG_ALERT, "could not expand string `%s'\n", route->pipe); |
345 destroy_table(var_table); | |
346 continue; | |
347 } | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
348 |
321 | 349 if (pipe_out(msg, msg->hdr_list, rcpt, cmd, (route->pipe_fromline ? MSGSTR_FROMLINE : 0) |
350 | (route->pipe_fromhack ? MSGSTR_FROMHACK : 0))) { | |
351 logwrite(LOG_NOTICE, "%s => %s@%s with pipe (cmd = '%s')\n", | |
352 msg->uid, rcpt->local_part, rcpt->domain, cmd); | |
353 addr_mark_delivered(rcpt); | |
354 ok = TRUE; | |
355 } else { | |
356 logwrite(LOG_ALERT, "pipe_out '%s' failed\n", route->pipe); | |
357 | |
358 if (route->connect_error_fail) { | |
359 addr_mark_failed(rcpt); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
360 } else { |
321 | 361 addr_mark_defered(rcpt); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
362 } |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
363 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
364 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
365 destroy_table(var_table); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
366 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
367 ok_fail = delivery_failures(msg, rcpt_list, "%s", strerror(errno)); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
368 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
369 if (flag) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
370 msg_free_data(msg); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
371 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
372 if (ok || ok_fail) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
373 deliver_finish(msgout); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
374 } |
0 | 375 } |
376 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
377 return ok; |
0 | 378 } |
379 | |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
380 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
381 ** deliver list of messages to one host and finishes them if the message was |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
382 ** delivered to at least one rcpt. |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
383 ** Returns TRUE if at least one msg was delivered to at least one rcpt. |
0 | 384 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
385 gboolean |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
386 deliver_msglist_host_smtp(connect_route *route, GList *msgout_list, |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
387 gchar *host, GList *res_list) |
0 | 388 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
389 gboolean ok = FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
390 GList *msgout_node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
391 smtp_base *psb; |
178 | 392 gint port = 25; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
393 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
394 /* paranoid check: */ |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
395 if (!msgout_list) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
396 logwrite(LOG_ALERT, "Ooops: empty list of messages in deliver_msglist_host()\n"); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
397 return FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
398 } |
0 | 399 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
400 if (!host) { |
179
3190e6864452
added comments to deliver.c (stuff to check)
meillo@marmaro.de
parents:
178
diff
changeset
|
401 /* XXX: what if mail_host isn't set? Is this possible? */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
402 host = route->mail_host->address; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
403 port = route->mail_host->port; |
178 | 404 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
405 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
406 if (route->wrapper) { |
372
b0708fac99dd
Fixed a problem with psb->remote_host, introduced in changeset 412385b57dc4
markus schnalke <meillo@marmaro.de>
parents:
370
diff
changeset
|
407 psb = smtp_out_open_child(route->wrapper); |
b0708fac99dd
Fixed a problem with psb->remote_host, introduced in changeset 412385b57dc4
markus schnalke <meillo@marmaro.de>
parents:
370
diff
changeset
|
408 if (psb) { |
b0708fac99dd
Fixed a problem with psb->remote_host, introduced in changeset 412385b57dc4
markus schnalke <meillo@marmaro.de>
parents:
370
diff
changeset
|
409 psb->remote_host = host; |
b0708fac99dd
Fixed a problem with psb->remote_host, introduced in changeset 412385b57dc4
markus schnalke <meillo@marmaro.de>
parents:
370
diff
changeset
|
410 } |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
411 } else { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
412 psb = smtp_out_open(host, port, res_list); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
413 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
414 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
415 if (!psb) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
416 /* smtp_out_open() failed */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
417 foreach(msgout_list, msgout_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
418 msg_out *msgout = (msg_out *) (msgout_node->data); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
419 GList *rcpt_node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
420 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
421 for (rcpt_node = g_list_first(msgout->rcpt_list); |
404 | 422 rcpt_node; |
423 rcpt_node = g_list_next(rcpt_node)) { | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
424 address *rcpt = (address *) (rcpt_node->data); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
425 gboolean ret = FALSE; |
0 | 426 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
427 addr_unmark_delivered(rcpt); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
428 if (route->connect_error_fail) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
429 addr_mark_failed(rcpt); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
430 } else { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
431 addr_mark_defered(rcpt); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
432 } |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
433 if (route->wrapper) { |
404 | 434 ret = delivery_failures(msgout->msg, |
435 msgout->rcpt_list, | |
436 "could not open " | |
437 "wrapper:\n\t%s", | |
438 strerror(errno)); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
439 } else { |
404 | 440 ret = delivery_failures(msgout->msg, |
441 msgout->rcpt_list, | |
442 "could not open " | |
443 "connection to %s:%d " | |
444 ":\n\t%s", host, port, | |
445 h_errno != 0 ? | |
446 hstrerror(h_errno) : | |
447 strerror(errno)); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
448 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
449 if (ret) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
450 deliver_finish(msgout); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
451 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
452 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
453 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
454 return ok; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
455 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
456 |
404 | 457 set_heloname(psb, route->helo_name ? route->helo_name : conf.host_name, |
458 route->do_correct_helo); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
459 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
460 #ifdef ENABLE_AUTH |
321 | 461 if (route->auth_name && route->auth_login && route->auth_secret) { |
404 | 462 set_auth(psb, route->auth_name, route->auth_login, |
463 route->auth_secret); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
464 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
465 #endif |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
466 if (!smtp_out_init(psb, route->instant_helo)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
467 /* smtp_out_init() failed */ |
404 | 468 if ((psb->error==smtp_fail) || (psb->error==smtp_trylater) || |
469 (psb->error==smtp_syntax)) { | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
470 smtp_out_quit(psb); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
471 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
472 foreach(msgout_list, msgout_node) { |
404 | 473 msg_out *msgout = |
474 (msg_out *)(msgout_node->data); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
475 smtp_out_mark_rcpts(psb, msgout->rcpt_list); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
476 |
404 | 477 if (delivery_failures(msgout->msg, |
478 msgout->rcpt_list, | |
479 "while connected with %s, " | |
480 "the server replied\n\t%s", | |
481 (route->wrapper) ? | |
482 "<wrapper>" : host, | |
483 psb->buffer)) { | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
484 deliver_finish(msgout); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
485 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
486 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
487 } |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
488 destroy_smtpbase(psb); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
489 return ok; |
0 | 490 } |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
491 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
492 if (!route->do_pipelining) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
493 psb->use_pipelining = FALSE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
494 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
495 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
496 foreach(msgout_list, msgout_node) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
497 msg_out *msgout = (msg_out *) (msgout_node->data); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
498 gboolean flag, ok_msg = FALSE, ok_fail = FALSE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
499 message *msg = msgout->msg; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
500 |
404 | 501 /* we may have to read the data at this point |
502 ** and remember if we did */ | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
503 flag = (msg->data_list == NULL); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
504 if (flag && !spool_read_data(msg)) { |
404 | 505 logwrite(LOG_ALERT, "could not open data spool " |
506 "file %s\n", msg->uid); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
507 break; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
508 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
509 |
404 | 510 smtp_out_msg(psb, msg, msgout->return_path, msgout->rcpt_list, |
511 msgout->hdr_list); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
512 |
404 | 513 ok_fail = delivery_failures(msg, msgout->rcpt_list, |
514 "while connected with %s, the server " | |
515 "replied\n\t%s", (route->wrapper) ? | |
516 "<wrapper>" : host, psb->buffer); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
517 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
518 if ((psb->error == smtp_eof) || (psb->error == smtp_timeout)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
519 /* connection lost */ |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
520 break; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
521 } else if (psb->error != smtp_ok) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
522 if (g_list_next(msgout_node) && !smtp_out_rset(psb)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
523 break; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
524 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
525 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
526 ok_msg = (psb->error == smtp_ok); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
527 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
528 if (flag) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
529 msg_free_data(msg); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
530 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
531 if (ok_msg) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
532 ok = TRUE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
533 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
534 if (ok_msg || ok_fail) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
535 deliver_finish(msgout); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
536 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
537 } |
404 | 538 if (psb->error == smtp_ok || (psb->error == smtp_fail) || |
539 (psb->error == smtp_trylater) || | |
540 (psb->error == smtp_syntax)) { | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
541 smtp_out_quit(psb); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
542 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
543 destroy_smtpbase(psb); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
544 return ok; |
0 | 545 } |
546 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
547 gboolean |
370 | 548 deliver_msglist_host(connect_route *route, GList *msgout_list, gchar *host, |
549 GList *res_list) | |
0 | 550 { |
551 | |
311
e230bcd0f1c6
removed protocol option from route config
meillo@marmaro.de
parents:
310
diff
changeset
|
552 if (route->pipe) { |
e230bcd0f1c6
removed protocol option from route config
meillo@marmaro.de
parents:
310
diff
changeset
|
553 DEBUG(5) debugf("with pipe\n"); |
404 | 554 return deliver_msglist_host_pipe(route, msgout_list, |
555 host, res_list); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
556 } else { |
311
e230bcd0f1c6
removed protocol option from route config
meillo@marmaro.de
parents:
310
diff
changeset
|
557 DEBUG(5) debugf("with smtp\n"); |
404 | 558 return deliver_msglist_host_smtp(route, msgout_list, |
559 host, res_list); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
560 } |
0 | 561 } |
562 | |
563 /* | |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
564 ** delivers messages in msgout_list using route |
0 | 565 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
566 gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
567 deliver_route_msgout_list(connect_route *route, GList *msgout_list) |
0 | 568 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
569 gboolean ok = FALSE; |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
570 GList *mo_ph_list; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
571 GList *mo_ph_node; |
0 | 572 |
404 | 573 DEBUG(5) debugf("deliver_route_msgout_list entered, route->name=%s\n", |
574 route->name); | |
0 | 575 |
179
3190e6864452
added comments to deliver.c (stuff to check)
meillo@marmaro.de
parents:
178
diff
changeset
|
576 if (route->mail_host) { |
404 | 577 /* easy: deliver everything to a smart host for relay */ |
370 | 578 return deliver_msglist_host(route, msgout_list, NULL, |
579 route->resolve_list); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
580 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
581 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
582 /* this is not easy... */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
583 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
584 mo_ph_list = route_msgout_list(route, msgout_list); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
585 /* okay, now we have ordered our messages by the hosts. */ |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
586 if (!mo_ph_list) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
587 return FALSE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
588 } |
0 | 589 |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
590 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
591 ** TODO: It would be nice to be able to fork for each host. |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
592 ** We cannot do that yet because of complications with finishing the |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
593 ** messages. Threads could be a solution because they use the same |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
594 ** memory. But we are not thread safe yet... |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
595 */ |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
596 foreach(mo_ph_list, mo_ph_node) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
597 msgout_perhost *mo_ph = (msgout_perhost *) (mo_ph_node->data); |
370 | 598 if (deliver_msglist_host(route, mo_ph->msgout_list, |
599 mo_ph->host, route->resolve_list)) { | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
600 ok = TRUE; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
601 } |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
602 destroy_msgout_perhost(mo_ph); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
603 } |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
604 g_list_free(mo_ph_list); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
605 return ok; |
0 | 606 } |
607 | |
608 /* | |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
609 ** calls route_prepare_msg() |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
610 ** delivers messages in msg_list using route by calling |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
611 ** deliver_route_msgout_list() |
0 | 612 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
613 gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
614 deliver_route_msg_list(connect_route *route, GList *msgout_list) |
0 | 615 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
616 GList *msgout_list_deliver = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
617 GList *msgout_node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
618 gboolean ok = TRUE; |
0 | 619 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
620 DEBUG(6) debugf("deliver_route_msg_list()\n"); |
0 | 621 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
622 foreach(msgout_list, msgout_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
623 msg_out *msgout = (msg_out *) (msgout_node->data); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
624 msg_out *msgout_cloned = clone_msg_out(msgout); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
625 GList *rcpt_list_non_delivered = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
626 GList *rcpt_node; |
0 | 627 |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
628 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
629 ** we have to delete already delivered rcpt's because a |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
630 ** previous route may have delivered to it |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
631 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
632 foreach(msgout_cloned->rcpt_list, rcpt_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
633 address *rcpt = (address *) (rcpt_node->data); |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
634 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
635 ** failed addresses already have been bounced; |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
636 ** there should be a better way to handle those. |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
637 */ |
404 | 638 if (!addr_is_delivered(rcpt) && |
639 !addr_is_failed(rcpt) && | |
640 !(rcpt->flags & ADDR_FLAG_LAST_ROUTE)){ | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
641 rcpt_list_non_delivered = g_list_append(rcpt_list_non_delivered, rcpt); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
642 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
643 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
644 g_list_free(msgout_cloned->rcpt_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
645 msgout_cloned->rcpt_list = rcpt_list_non_delivered; |
0 | 646 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
647 if (!msgout_cloned->rcpt_list) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
648 destroy_msg_out(msgout_cloned); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
649 continue; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
650 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
651 |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
315
diff
changeset
|
652 /* filter by allowed envelope sender */ |
404 | 653 if (!route_sender_is_allowed(route, msgout->msg->return_path)){ |
654 DEBUG(6) debugf("sender `%s' is not allowed for this " | |
655 "route\n", msgout->msg->return_path); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
656 destroy_msg_out(msgout_cloned); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
657 continue; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
658 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
659 |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
315
diff
changeset
|
660 /* filter by allowed envelope rcpts */ |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
661 GList *rcpt_list_allowed = NULL; |
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
662 GList *rcpt_list_notallowed = NULL; |
370 | 663 route_split_rcpts(route, msgout_cloned->rcpt_list, |
664 &rcpt_list_allowed, &rcpt_list_notallowed); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
665 if (!rcpt_list_allowed) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
666 destroy_msg_out(msgout_cloned); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
667 continue; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
668 } |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
315
diff
changeset
|
669 |
370 | 670 logwrite(LOG_NOTICE, "%s using '%s'\n", msgout->msg->uid, |
671 route->name); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
672 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
673 g_list_free(msgout_cloned->rcpt_list); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
674 msgout_cloned->rcpt_list = rcpt_list_allowed; |
0 | 675 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
676 if (route->last_route) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
677 GList *rcpt_node; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
678 foreach(msgout_cloned->rcpt_list, rcpt_node) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
679 address *rcpt = (address *) (rcpt_node->data); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
680 rcpt->flags |= ADDR_FLAG_LAST_ROUTE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
681 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
682 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
683 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
684 route_prepare_msgout(route, msgout_cloned); |
404 | 685 msgout_list_deliver = g_list_append(msgout_list_deliver, |
686 msgout_cloned); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
687 } |
0 | 688 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
689 if (msgout_list_deliver) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
690 if (deliver_route_msgout_list(route, msgout_list_deliver)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
691 ok = TRUE; |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
692 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
693 destroy_msg_out_list(msgout_list_deliver); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
694 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
695 return ok; |
0 | 696 } |
697 | |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
698 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
699 ** copy pointers of delivered addresses to the msg's non_rcpt_list, |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
700 ** to make sure that they will not be delivered again. |
0 | 701 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
702 void |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
703 update_non_rcpt_list(msg_out *msgout) |
0 | 704 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
705 GList *rcpt_node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
706 message *msg = msgout->msg; |
0 | 707 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
708 foreach(msgout->rcpt_list, rcpt_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
709 address *rcpt = (address *) (rcpt_node->data); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
710 if (addr_is_delivered(rcpt) || addr_is_failed(rcpt)) { |
404 | 711 msg->non_rcpt_list = g_list_append(msg->non_rcpt_list, |
712 rcpt); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
713 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
714 } |
0 | 715 } |
716 | |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
717 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
718 ** after delivery attempts, we check if there are any rcpt addresses left in |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
719 ** the message. If all addresses have been completed, the spool files will be |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
720 ** deleted, otherwise the header spool will be written back. We never changed |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
721 ** the data spool, so there is no need to write that back. |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
722 ** |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
723 ** returns TRUE if all went well. |
0 | 724 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
725 gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
726 deliver_finish(msg_out *msgout) |
0 | 727 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
728 GList *rcpt_node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
729 message *msg = msgout->msg; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
730 gboolean finished = TRUE; |
0 | 731 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
732 update_non_rcpt_list(msgout); |
0 | 733 |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
734 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
735 ** we NEVER made copies of the addresses, flags affecting addresses |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
736 ** were always set on the original address structs |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
737 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
738 foreach(msg->rcpt_list, rcpt_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
739 address *rcpt = (address *) (rcpt_node->data); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
740 if (!addr_is_finished_children(rcpt)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
741 finished = FALSE; |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
742 } else { |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
743 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
744 ** if ALL children have been delivered, mark parent as |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
745 ** delivered. if there is one or more not delivered, |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
746 ** it must have failed, we mark the parent as failed |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
747 ** as well. |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
748 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
749 if (addr_is_delivered_children(rcpt)) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
750 addr_mark_delivered(rcpt); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
751 } else { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
752 addr_mark_failed(rcpt); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
753 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
754 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
755 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
756 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
757 if (finished) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
758 if (spool_delete_all(msg)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
759 logwrite(LOG_NOTICE, "%s completed.\n", msg->uid); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
760 return TRUE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
761 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
762 return FALSE; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
763 } |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
764 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
765 /* one not delivered address was found */ |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
766 if (!spool_write(msg, FALSE)) { |
404 | 767 logwrite(LOG_ALERT, "could not write back spool header " |
768 "for %s\n", msg->uid); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
769 return FALSE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
770 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
771 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
772 DEBUG(2) debugf("spool header for %s written back.\n", msg->uid); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
773 return TRUE; |
0 | 774 } |
775 | |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
776 int |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
777 deliver_remote(GList *remote_msgout_list) |
0 | 778 { |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
779 int ok = TRUE; |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
780 GList *route_list = NULL; |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
781 GList *route_node; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
782 GList *rf_list = NULL; |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
783 gchar *connect_name = NULL; |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
784 |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
785 if (!remote_msgout_list) { |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
786 return FALSE; |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
787 } |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
788 |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
789 /* perma routes */ |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
790 if (conf.perma_routes) { |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
791 DEBUG(5) debugf("processing perma_routes\n"); |
0 | 792 |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
793 route_list = read_route_list(conf.perma_routes, TRUE); |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
794 foreach(route_list, route_node) { |
404 | 795 connect_route *route = |
796 (connect_route *) (route_node->data); | |
797 if (!deliver_route_msg_list(route, | |
798 remote_msgout_list)) { | |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
799 ok = FALSE; |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
800 } |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
801 } |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
802 destroy_route_list(route_list); |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
803 } |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
804 |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
805 /* query routes */ |
310
f10a56dc7481
reworked online_detect to the simpler online_query
meillo@marmaro.de
parents:
280
diff
changeset
|
806 connect_name = online_query(); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
807 if (!connect_name) { |
344
0410c8aabac2
improved comments and debug messages
markus schnalke <meillo@marmaro.de>
parents:
343
diff
changeset
|
808 DEBUG(5) debugf("online query returned false\n"); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
809 return FALSE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
810 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
811 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
812 /* we are online! */ |
344
0410c8aabac2
improved comments and debug messages
markus schnalke <meillo@marmaro.de>
parents:
343
diff
changeset
|
813 DEBUG(5) debugf("processing query_routes\n"); |
404 | 814 logwrite(LOG_NOTICE, "detected online configuration `%s'\n", |
815 connect_name); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
816 |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
817 rf_list = (GList *) table_find(conf.query_routes, connect_name); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
818 if (!rf_list) { |
404 | 819 logwrite(LOG_ALERT, "route list with name '%s' not found.\n", |
820 connect_name); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
821 return FALSE; |
0 | 822 } |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
823 |
321 | 824 route_list = read_route_list(rf_list, FALSE); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
825 if (!route_list) { |
404 | 826 logwrite(LOG_ALERT, "could not read route list '%s'\n", |
827 connect_name); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
828 return FALSE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
829 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
830 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
831 foreach(route_list, route_node) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
832 connect_route *route = (connect_route *) (route_node->data); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
833 /* TODO: ok gets overwritten */ |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
834 ok = deliver_route_msg_list(route, remote_msgout_list); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
835 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
836 destroy_route_list(route_list); |
344
0410c8aabac2
improved comments and debug messages
markus schnalke <meillo@marmaro.de>
parents:
343
diff
changeset
|
837 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
838 return ok; |
0 | 839 } |
840 | |
321 | 841 /* |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
842 ** This function splits the list of rcpt addresses |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
843 ** into local and remote addresses and processes them accordingly. |
321 | 844 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
845 gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
846 deliver_msg_list(GList *msg_list, guint flags) |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
847 { |
343
9149d893eb52
refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents:
321
diff
changeset
|
848 GList *msgout_list = NULL; |
9149d893eb52
refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents:
321
diff
changeset
|
849 GList *msg_node; |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
850 GList *local_msgout_list = NULL; |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
851 GList *remote_msgout_list = NULL; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
852 GList *msgout_node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
853 GList *alias_table = NULL; |
387
a408411ff8df
Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents:
375
diff
changeset
|
854 GList *globalias_table = NULL; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
855 gboolean ok = TRUE; |
0 | 856 |
343
9149d893eb52
refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents:
321
diff
changeset
|
857 /* create msgout_list */ |
9149d893eb52
refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents:
321
diff
changeset
|
858 foreach(msg_list, msg_node) { |
9149d893eb52
refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents:
321
diff
changeset
|
859 message *msg = (message *) msg_node->data; |
9149d893eb52
refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents:
321
diff
changeset
|
860 msgout_list = g_list_append(msgout_list, create_msg_out(msg)); |
9149d893eb52
refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents:
321
diff
changeset
|
861 } |
9149d893eb52
refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents:
321
diff
changeset
|
862 |
387
a408411ff8df
Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents:
375
diff
changeset
|
863 if (conf.globalias_file) { |
a408411ff8df
Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents:
375
diff
changeset
|
864 globalias_table = table_read(conf.globalias_file, ':'); |
a408411ff8df
Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents:
375
diff
changeset
|
865 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
866 if (conf.alias_file) { |
17
6c59dedd06be
fixed delivery with empty or non-existent alias file
meillo@marmaro.de
parents:
15
diff
changeset
|
867 alias_table = table_read(conf.alias_file, ':'); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
868 } |
0 | 869 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
870 /* sort messages for different deliveries */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
871 foreach(msgout_list, msgout_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
872 msg_out *msgout = (msg_out *) (msgout_node->data); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
873 GList *rcpt_list; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
874 GList *local_rcpt_list = NULL; |
237
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
224
diff
changeset
|
875 GList *other_rcpt_list = NULL; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
876 |
114 | 877 if (!spool_lock(msgout->msg->uid)) { |
404 | 878 DEBUG(5) debugf("spool_lock(%s) failed.\n", |
879 msgout->msg->uid); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
880 continue; |
114 | 881 } |
882 DEBUG(5) debugf("spool_lock(%s)\n", msgout->msg->uid); | |
0 | 883 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
884 rcpt_list = g_list_copy(msgout->msg->rcpt_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
885 if (conf.log_user) { |
404 | 886 address *addr = create_address_qualified(conf.log_user, |
887 TRUE, conf.host_name); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
888 if (addr) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
889 rcpt_list = g_list_prepend(rcpt_list, addr); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
890 } else { |
404 | 891 logwrite(LOG_ALERT, "invalid log_user " |
892 "address `%s', ignoring\n", | |
893 conf.log_user); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
894 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
895 } |
387
a408411ff8df
Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents:
375
diff
changeset
|
896 if (globalias_table) { |
a408411ff8df
Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents:
375
diff
changeset
|
897 GList *globaliased_rcpt_list; |
417
8fedb93e9b72
Added comments and debug messages.
markus schnalke <meillo@marmaro.de>
parents:
404
diff
changeset
|
898 |
8fedb93e9b72
Added comments and debug messages.
markus schnalke <meillo@marmaro.de>
parents:
404
diff
changeset
|
899 DEBUG(5) debugf("Doing globalias expansion\n"); |
387
a408411ff8df
Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents:
375
diff
changeset
|
900 globaliased_rcpt_list = alias_expand(globalias_table, |
a408411ff8df
Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents:
375
diff
changeset
|
901 rcpt_list, |
a408411ff8df
Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents:
375
diff
changeset
|
902 msgout->msg->non_rcpt_list, 1); |
a408411ff8df
Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents:
375
diff
changeset
|
903 g_list_free(rcpt_list); |
a408411ff8df
Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents:
375
diff
changeset
|
904 rcpt_list = globaliased_rcpt_list; |
a408411ff8df
Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents:
375
diff
changeset
|
905 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
906 if (alias_table) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
907 GList *aliased_rcpt_list; |
417
8fedb93e9b72
Added comments and debug messages.
markus schnalke <meillo@marmaro.de>
parents:
404
diff
changeset
|
908 |
8fedb93e9b72
Added comments and debug messages.
markus schnalke <meillo@marmaro.de>
parents:
404
diff
changeset
|
909 DEBUG(5) debugf("Doing alias expansion\n"); |
387
a408411ff8df
Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents:
375
diff
changeset
|
910 aliased_rcpt_list = alias_expand(alias_table, |
a408411ff8df
Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents:
375
diff
changeset
|
911 rcpt_list, |
a408411ff8df
Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents:
375
diff
changeset
|
912 msgout->msg->non_rcpt_list, 0); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
913 g_list_free(rcpt_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
914 rcpt_list = aliased_rcpt_list; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
915 } |
0 | 916 |
404 | 917 /* split_rcpts(rcpt_list, NULL, &local_rcpt_list, NULL, |
918 ** &other_rcpt_list); */ | |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
919 local_rcpt_list = local_rcpts(rcpt_list); |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
920 other_rcpt_list = remote_rcpts(rcpt_list); |
237
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
224
diff
changeset
|
921 g_list_free(rcpt_list); |
0 | 922 |
237
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
224
diff
changeset
|
923 /* local recipients */ |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
224
diff
changeset
|
924 if ((flags & DLVR_LOCAL) && local_rcpt_list) { |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
224
diff
changeset
|
925 msg_out *local_msgout = clone_msg_out(msgout); |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
224
diff
changeset
|
926 local_msgout->rcpt_list = local_rcpt_list; |
404 | 927 local_msgout_list = g_list_append(local_msgout_list, |
928 local_msgout); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
929 } |
0 | 930 |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
931 /* remote recipients, requires online delivery */ |
237
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
224
diff
changeset
|
932 if ((flags & DLVR_ONLINE) && other_rcpt_list) { |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
933 msg_out *remote_msgout = clone_msg_out(msgout); |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
934 remote_msgout->rcpt_list = other_rcpt_list; |
404 | 935 remote_msgout_list = g_list_append(remote_msgout_list, |
936 remote_msgout); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
937 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
938 } |
0 | 939 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
940 if (alias_table) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
941 destroy_table(alias_table); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
942 } |
387
a408411ff8df
Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents:
375
diff
changeset
|
943 if (globalias_table) { |
a408411ff8df
Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents:
375
diff
changeset
|
944 destroy_table(globalias_table); |
a408411ff8df
Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents:
375
diff
changeset
|
945 } |
0 | 946 |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
947 /* process local/remote msgout lists -> delivery */ |
237
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
224
diff
changeset
|
948 |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
224
diff
changeset
|
949 if (local_msgout_list) { |
114 | 950 DEBUG(5) debugf("local_msgout_list\n"); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
951 foreach(local_msgout_list, msgout_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
952 msg_out *msgout = (msg_out *) (msgout_node->data); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
953 if (!deliver_local(msgout)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
954 ok = FALSE; |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
955 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
956 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
957 destroy_msg_out_list(local_msgout_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
958 } |
0 | 959 |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
960 if (remote_msgout_list) { |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
961 DEBUG(5) debugf("remote_msgout_list\n"); |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
962 deliver_remote(remote_msgout_list); |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
963 destroy_msg_out_list(remote_msgout_list); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
964 } |
0 | 965 |
344
0410c8aabac2
improved comments and debug messages
markus schnalke <meillo@marmaro.de>
parents:
343
diff
changeset
|
966 /* unlock spool files */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
967 foreach(msgout_list, msgout_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
968 msg_out *msgout = (msg_out *) (msgout_node->data); |
114 | 969 if (spool_unlock(msgout->msg->uid)) { |
404 | 970 DEBUG(5) debugf("spool_unlock(%s)\n", |
971 msgout->msg->uid); | |
114 | 972 } else { |
404 | 973 DEBUG(5) debugf("spool_unlock(%s) failed.\n", |
974 msgout->msg->uid); | |
114 | 975 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
976 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
977 destroy_msg_out_list(msgout_list); |
0 | 978 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
979 return ok; |
0 | 980 } |
981 | |
321 | 982 /* |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
983 ** deliver() is called when a message has just been received |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
984 ** (mode_accept and smtp_in) and should be delivered immediately |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
985 ** (neither -odq nor do_queue). Only this one message will be tried to |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
986 ** deliver then. |
0 | 987 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
988 gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
989 deliver(message *msg) |
0 | 990 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
991 gboolean ok; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
992 GList *msg_list = g_list_append(NULL, msg); |
0 | 993 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
994 ok = deliver_msg_list(msg_list, DLVR_ALL); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
995 g_list_free(msg_list); |
0 | 996 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
997 return ok; |
0 | 998 } |