Mercurial > masqmail
annotate src/deliver.c @ 370:d86d7b4b8995
Broke long lines.
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Tue, 25 Oct 2011 13:50:27 +0200 |
parents | b27f66555ba8 |
children | b0708fac99dd |
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)) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
47 if ((now - msg->received_time) >= conf.max_defer_time) { |
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 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
50 defered_list = g_list_prepend(defered_list, rcpt); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
51 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
52 } |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
53 if (addr_is_failed(rcpt)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
54 failed_list = g_list_prepend(failed_list, rcpt); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
55 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
56 } |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
57 if (failed_list) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
58 ok_fail = fail_msg(msg, conf.errmsg_file, failed_list, err_fmt, args); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
59 g_list_free(failed_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
60 } |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
61 if (defered_list) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
62 ok_warn = warn_msg(msg, conf.warnmsg_file, defered_list, err_fmt, args); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
63 g_list_free(defered_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
64 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
65 va_end(args); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
66 return ok_fail && ok_warn; |
0 | 67 } |
68 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
69 static gint |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
70 _g_list_strcasecmp(gconstpointer a, gconstpointer b) |
0 | 71 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
72 return (gint) strcasecmp(a, b); |
0 | 73 } |
74 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
75 gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
76 deliver_local_mbox(message *msg, GList *hdr_list, address *rcpt, address *env_addr) |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
77 { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
78 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
|
79 if (append_file(msg, hdr_list, rcpt->local_part)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
80 if (env_addr != rcpt) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
81 logwrite(LOG_NOTICE, "%s => %s@%s <%s@%s> with mbox\n", msg->uid, rcpt->local_part, rcpt->domain, env_addr->local_part, env_addr->domain); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
82 } else { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
83 logwrite(LOG_NOTICE, "%s => <%s@%s> with mbox\n", msg->uid, rcpt->local_part, rcpt->domain); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
84 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
85 addr_mark_delivered(rcpt); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
86 return TRUE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
87 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
88 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
89 /* prevents 'Resource temporarily unavailable (11)' */ |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
90 if (errno != EAGAIN) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
91 addr_mark_failed(rcpt); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
92 } else { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
93 addr_mark_defered(rcpt); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
94 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
95 return FALSE; |
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 gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
99 deliver_local_pipe(message *msg, GList *hdr_list, address *rcpt, address *env_addr) |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
100 { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
101 guint flags; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
102 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
103 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
|
104 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
105 flags = (conf.pipe_fromline) ? MSGSTR_FROMLINE : 0; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
106 flags |= (conf.pipe_fromhack) ? MSGSTR_FROMHACK : 0; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
107 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
|
108 logwrite(LOG_NOTICE, "%s => %s <%s@%s> with pipe\n", |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
109 msg->uid, rcpt->local_part, env_addr->local_part, env_addr->domain); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
110 addr_mark_delivered(rcpt); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
111 return TRUE; |
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 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
114 if ((errno != (1024 + EX_TEMPFAIL)) && (errno != EAGAIN)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
115 addr_mark_failed(rcpt); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
116 } else { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
117 addr_mark_defered(rcpt); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
118 /* 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
|
119 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
120 return FALSE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
121 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
122 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
123 gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
124 deliver_local_mda(message *msg, GList *hdr_list, address *rcpt, address *env_addr) |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
125 { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
126 gboolean ok = FALSE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
127 gchar *cmd = g_malloc(256); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
128 GList *var_table = var_table_rcpt(var_table_msg(NULL, msg), rcpt); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
129 guint flags; |
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 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
|
132 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
133 if (!expand(var_table, conf.mda, cmd, 256)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
134 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
|
135 destroy_table(var_table); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
136 return FALSE; |
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 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
139 flags = (conf.mda_fromline) ? MSGSTR_FROMLINE : 0; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
140 flags |= (conf.mda_fromhack) ? MSGSTR_FROMHACK : 0; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
141 if (pipe_out(msg, hdr_list, rcpt, cmd, flags)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
142 logwrite(LOG_NOTICE, "%s => %s@%s with mda (cmd = '%s')\n", |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
143 msg->uid, rcpt->local_part, rcpt->domain, cmd); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
144 addr_mark_delivered(rcpt); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
145 ok = TRUE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
146 } else if ((errno != (1024 + EX_TEMPFAIL)) && (errno != EAGAIN)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
147 addr_mark_failed(rcpt); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
148 } else { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
149 addr_mark_defered(rcpt); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
150 /* 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
|
151 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
152 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
153 destroy_table(var_table); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
154 return ok; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
155 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
156 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
157 gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
158 deliver_local(msg_out *msgout) |
0 | 159 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
160 message *msg = msgout->msg; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
161 GList *rcpt_list = msgout->rcpt_list; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
162 GList *rcpt_node; |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
163 gboolean ok = FALSE, flag = FALSE, ok_fail = FALSE; |
0 | 164 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
165 DEBUG(5) debugf("deliver_local entered\n"); |
0 | 166 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
167 flag = (msg->data_list == NULL); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
168 if (flag && !spool_read_data(msg)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
169 logwrite(LOG_ALERT, "could not open data spool file for %s\n", msg->uid); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
170 return FALSE; |
0 | 171 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
172 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
173 for (rcpt_node = g_list_first(rcpt_list); rcpt_node; rcpt_node = g_list_next(rcpt_node)) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
174 GList *hdr_list; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
175 address *rcpt = (address *) (rcpt_node->data); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
176 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
|
177 address *ret_path = msg->return_path; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
178 header *retpath_hdr, *envto_hdr; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
179 |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
180 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
181 ** 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
|
182 ** 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
|
183 ** 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
|
184 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
185 hdr_list = g_list_copy(msg->hdr_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
186 retpath_hdr = create_header(HEAD_ENVELOPE_TO, "Envelope-to: %s\n", addr_string(env_addr)); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
187 envto_hdr = create_header(HEAD_RETURN_PATH, "Return-path: %s\n", addr_string(ret_path)); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
188 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
189 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
|
190 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
|
191 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
192 if (rcpt->local_part[0] == '|') { |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
193 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
194 ** 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
|
195 ** 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
|
196 */ |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
197 if (deliver_local_pipe(msg, hdr_list, rcpt, env_addr)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
198 ok = TRUE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
199 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
200 } else { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
201 /* figure out which mailbox type should be used for this user */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
202 gchar *user = rcpt->local_part; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
203 gchar *mbox_type = conf.mbox_default; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
204 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
205 if (g_list_find_custom (conf.mbox_users, user, _g_list_strcasecmp)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
206 mbox_type = "mbox"; |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
207 } else if (g_list_find_custom (conf.mda_users, user, _g_list_strcasecmp)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
208 mbox_type = "mda"; |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
209 } |
0 | 210 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
211 if (strcmp(mbox_type, "mbox") == 0) { |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
212 if (deliver_local_mbox(msg, hdr_list, rcpt, env_addr)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
213 ok = TRUE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
214 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
215 } 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
|
216 if (conf.mda) { |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
217 if (deliver_local_mda(msg, hdr_list, rcpt, env_addr)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
218 ok = TRUE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
219 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
220 } else { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
221 logwrite(LOG_ALERT, "mbox type is mda, but no mda command given in configuration\n"); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
222 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
223 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
224 } else { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
225 logwrite(LOG_ALERT, "unknown mbox type '%s'\n", mbox_type); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
226 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
227 } |
0 | 228 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
229 destroy_header(retpath_hdr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
230 destroy_header(envto_hdr); |
0 | 231 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
232 g_list_free(hdr_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
233 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
234 ok_fail = delivery_failures(msg, rcpt_list, "%s (%d)", ext_strerror(errno), errno); |
0 | 235 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
236 if (flag) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
237 msg_free_data(msg); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
238 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
239 if (ok || ok_fail) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
240 deliver_finish(msgout); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
241 } |
0 | 242 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
243 return ok; |
0 | 244 } |
245 | |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
246 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
247 ** 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
|
248 ** 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
|
249 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
250 void |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
251 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
|
252 GList **p_nonlocal_list) |
0 | 253 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
254 GList *rcpt_node; |
0 | 255 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
256 foreach(rcpt_list, rcpt_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
257 address *rcpt = (address *) (rcpt_node->data); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
258 GList *dom_node; |
0 | 259 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
260 DEBUG(5) debugf("checking address %s\n", rcpt->address); |
0 | 261 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
262 /* search for local host list: */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
263 foreach(conf.local_hosts, dom_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
264 if (strcasecmp(dom_node->data, rcpt->domain) == 0) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
265 *p_local_list = g_list_append(*p_local_list, rcpt); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
266 DEBUG(5) debugf("<%s@%s> is local\n", rcpt->local_part, rcpt->domain); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
267 break; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
268 } else { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
269 *p_nonlocal_list = g_list_append(*p_nonlocal_list, rcpt); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
270 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
271 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
272 } |
0 | 273 } |
274 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
275 gboolean |
370 | 276 deliver_msglist_host_pipe(connect_route *route, GList *msgout_list, |
277 gchar *host, GList *res_list) | |
0 | 278 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
279 gboolean ok = TRUE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
280 GList *msgout_node; |
0 | 281 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
282 DEBUG(5) debugf("deliver_msglist_host_pipe entered\n"); |
0 | 283 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
284 foreach(msgout_list, msgout_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
285 msg_out *msgout = (msg_out *) (msgout_node->data); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
286 gboolean flag, ok_fail = FALSE; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
287 message *msg = msgout->msg; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
288 GList *rcpt_node, *rcpt_list = msgout->rcpt_list; |
0 | 289 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
290 DEBUG(1) debugf("attempting to deliver %s with pipe\n", msg->uid); |
0 | 291 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
292 flag = (msg->data_list == NULL); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
293 if (flag && !spool_read_data(msg)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
294 logwrite(LOG_ALERT, "could not open data spool file for %s\n", msg->uid); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
295 continue; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
296 } |
0 | 297 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
298 ok = FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
299 foreach(rcpt_list, rcpt_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
300 address *rcpt = (address *) (rcpt_node->data); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
301 gchar *cmd = g_malloc(256); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
302 GList *var_table = var_table_rcpt(var_table_msg(NULL, msg), rcpt); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
303 |
321 | 304 DEBUG(1) debugf("attempting to deliver %s to %s@%s with pipe\n", |
305 msg->uid, rcpt->local_part, rcpt->domain); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
306 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
307 if (!expand(var_table, route->pipe, cmd, 256)) { |
321 | 308 logwrite(LOG_ALERT, "could not expand string `%s'\n", route->pipe); |
309 destroy_table(var_table); | |
310 continue; | |
311 } | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
312 |
321 | 313 if (pipe_out(msg, msg->hdr_list, rcpt, cmd, (route->pipe_fromline ? MSGSTR_FROMLINE : 0) |
314 | (route->pipe_fromhack ? MSGSTR_FROMHACK : 0))) { | |
315 logwrite(LOG_NOTICE, "%s => %s@%s with pipe (cmd = '%s')\n", | |
316 msg->uid, rcpt->local_part, rcpt->domain, cmd); | |
317 addr_mark_delivered(rcpt); | |
318 ok = TRUE; | |
319 } else { | |
320 logwrite(LOG_ALERT, "pipe_out '%s' failed\n", route->pipe); | |
321 | |
322 if (route->connect_error_fail) { | |
323 addr_mark_failed(rcpt); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
324 } else { |
321 | 325 addr_mark_defered(rcpt); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
326 } |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
327 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
328 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
329 destroy_table(var_table); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
330 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
331 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
|
332 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
333 if (flag) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
334 msg_free_data(msg); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
335 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
336 if (ok || ok_fail) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
337 deliver_finish(msgout); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
338 } |
0 | 339 } |
340 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
341 return ok; |
0 | 342 } |
343 | |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
344 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
345 ** 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
|
346 ** 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
|
347 ** Returns TRUE if at least one msg was delivered to at least one rcpt. |
0 | 348 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
349 gboolean |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
350 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
|
351 gchar *host, GList *res_list) |
0 | 352 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
353 gboolean ok = FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
354 GList *msgout_node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
355 smtp_base *psb; |
178 | 356 gint port = 25; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
357 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
358 /* paranoid check: */ |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
359 if (!msgout_list) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
360 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
|
361 return FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
362 } |
0 | 363 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
364 if (!host) { |
179
3190e6864452
added comments to deliver.c (stuff to check)
meillo@marmaro.de
parents:
178
diff
changeset
|
365 /* 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
|
366 host = route->mail_host->address; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
367 port = route->mail_host->port; |
178 | 368 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
369 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
370 if (route->wrapper) { |
321 | 371 psb = smtp_out_open_child(route->wrapper, host); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
372 } else { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
373 psb = smtp_out_open(host, port, res_list); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
374 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
375 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
376 if (!psb) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
377 /* smtp_out_open() failed */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
378 foreach(msgout_list, msgout_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
379 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
|
380 GList *rcpt_node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
381 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
382 for (rcpt_node = g_list_first(msgout->rcpt_list); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
383 rcpt_node; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
384 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
|
385 address *rcpt = (address *) (rcpt_node->data); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
386 gboolean ret = FALSE; |
0 | 387 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
388 addr_unmark_delivered(rcpt); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
389 if (route->connect_error_fail) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
390 addr_mark_failed(rcpt); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
391 } else { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
392 addr_mark_defered(rcpt); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
393 } |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
394 if (route->wrapper) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
395 ret = delivery_failures(msgout->msg, msgout->rcpt_list, "could not open wrapper:\n\t%s", strerror(errno)); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
396 } else { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
397 ret = delivery_failures(msgout->msg, msgout->rcpt_list, "could not open connection to %s:%d :\n\t%s", host, port, h_errno != 0 ? hstrerror(h_errno) : strerror(errno)); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
398 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
399 if (ret) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
400 deliver_finish(msgout); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
401 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
402 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
403 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
404 return ok; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
405 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
406 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
407 set_heloname(psb, route->helo_name ? route->helo_name : conf.host_name, route->do_correct_helo); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
408 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
409 #ifdef ENABLE_AUTH |
321 | 410 if (route->auth_name && route->auth_login && route->auth_secret) { |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
411 set_auth(psb, route->auth_name, route->auth_login, route->auth_secret); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
412 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
413 #endif |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
414 if (!smtp_out_init(psb, route->instant_helo)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
415 /* smtp_out_init() failed */ |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
416 if ((psb->error==smtp_fail) || (psb->error==smtp_trylater) || (psb->error==smtp_syntax)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
417 smtp_out_quit(psb); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
418 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
419 foreach(msgout_list, msgout_node) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
420 msg_out *msgout = (msg_out *) (msgout_node->data); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
421 smtp_out_mark_rcpts(psb, msgout->rcpt_list); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
422 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
423 if (delivery_failures(msgout->msg, msgout->rcpt_list, "while connected with %s, the server replied\n\t%s", host, psb->buffer)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
424 deliver_finish(msgout); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
425 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
426 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
427 } |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
428 destroy_smtpbase(psb); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
429 return ok; |
0 | 430 } |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
431 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
432 if (!route->do_pipelining) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
433 psb->use_pipelining = FALSE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
434 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
435 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
436 foreach(msgout_list, msgout_node) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
437 msg_out *msgout = (msg_out *) (msgout_node->data); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
438 gboolean flag, ok_msg = FALSE, ok_fail = FALSE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
439 message *msg = msgout->msg; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
440 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
441 /* we may have to read the data at this point and remember if we did */ |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
442 flag = (msg->data_list == NULL); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
443 if (flag && !spool_read_data(msg)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
444 logwrite(LOG_ALERT, "could not open data spool file %s\n", msg->uid); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
445 break; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
446 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
447 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
448 smtp_out_msg(psb, msg, msgout->return_path, msgout->rcpt_list, msgout->hdr_list); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
449 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
450 ok_fail = delivery_failures(msg, msgout->rcpt_list, "while connected with %s, the server replied\n\t%s", host, psb->buffer); |
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 if ((psb->error == smtp_eof) || (psb->error == smtp_timeout)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
453 /* connection lost */ |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
454 break; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
455 } else if (psb->error != smtp_ok) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
456 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
|
457 break; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
458 } |
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 ok_msg = (psb->error == smtp_ok); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
461 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
462 if (flag) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
463 msg_free_data(msg); |
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 if (ok_msg) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
466 ok = TRUE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
467 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
468 if (ok_msg || ok_fail) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
469 deliver_finish(msgout); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
470 } |
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 if (psb->error == smtp_ok || (psb->error == smtp_fail) |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
473 || (psb->error == smtp_trylater) || (psb->error == smtp_syntax)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
474 smtp_out_quit(psb); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
475 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
476 destroy_smtpbase(psb); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
477 return ok; |
0 | 478 } |
479 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
480 gboolean |
370 | 481 deliver_msglist_host(connect_route *route, GList *msgout_list, gchar *host, |
482 GList *res_list) | |
0 | 483 { |
484 | |
311
e230bcd0f1c6
removed protocol option from route config
meillo@marmaro.de
parents:
310
diff
changeset
|
485 if (route->pipe) { |
e230bcd0f1c6
removed protocol option from route config
meillo@marmaro.de
parents:
310
diff
changeset
|
486 DEBUG(5) debugf("with pipe\n"); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
487 return deliver_msglist_host_pipe(route, msgout_list, host, res_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
488 } else { |
311
e230bcd0f1c6
removed protocol option from route config
meillo@marmaro.de
parents:
310
diff
changeset
|
489 DEBUG(5) debugf("with smtp\n"); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
490 return deliver_msglist_host_smtp(route, msgout_list, host, res_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
491 } |
0 | 492 } |
493 | |
494 /* | |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
495 ** delivers messages in msgout_list using route |
0 | 496 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
497 gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
498 deliver_route_msgout_list(connect_route *route, GList *msgout_list) |
0 | 499 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
500 gboolean ok = FALSE; |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
501 GList *mo_ph_list; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
502 GList *mo_ph_node; |
0 | 503 |
15 | 504 DEBUG(5) debugf("deliver_route_msgout_list entered, route->name = %s\n", route->name); |
0 | 505 |
179
3190e6864452
added comments to deliver.c (stuff to check)
meillo@marmaro.de
parents:
178
diff
changeset
|
506 if (route->mail_host) { |
3190e6864452
added comments to deliver.c (stuff to check)
meillo@marmaro.de
parents:
178
diff
changeset
|
507 /* this is easy... deliver everything to a smart host for relay */ |
370 | 508 return deliver_msglist_host(route, msgout_list, NULL, |
509 route->resolve_list); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
510 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
511 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
512 /* this is not easy... */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
513 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
514 mo_ph_list = route_msgout_list(route, msgout_list); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
515 /* 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
|
516 if (!mo_ph_list) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
517 return FALSE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
518 } |
0 | 519 |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
520 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
521 ** 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
|
522 ** 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
|
523 ** 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
|
524 ** 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
|
525 */ |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
526 foreach(mo_ph_list, mo_ph_node) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
527 msgout_perhost *mo_ph = (msgout_perhost *) (mo_ph_node->data); |
370 | 528 if (deliver_msglist_host(route, mo_ph->msgout_list, |
529 mo_ph->host, route->resolve_list)) { | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
530 ok = TRUE; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
531 } |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
532 destroy_msgout_perhost(mo_ph); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
533 } |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
534 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
|
535 return ok; |
0 | 536 } |
537 | |
538 /* | |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
539 ** calls route_prepare_msg() |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
540 ** 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
|
541 ** deliver_route_msgout_list() |
0 | 542 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
543 gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
544 deliver_route_msg_list(connect_route *route, GList *msgout_list) |
0 | 545 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
546 GList *msgout_list_deliver = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
547 GList *msgout_node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
548 gboolean ok = TRUE; |
0 | 549 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
550 DEBUG(6) debugf("deliver_route_msg_list()\n"); |
0 | 551 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
552 foreach(msgout_list, msgout_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
553 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
|
554 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
|
555 GList *rcpt_list_non_delivered = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
556 GList *rcpt_node; |
0 | 557 |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
558 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
559 ** 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
|
560 ** 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
|
561 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
562 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
|
563 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
|
564 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
565 ** 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
|
566 ** 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
|
567 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
568 if (!addr_is_delivered(rcpt) && !addr_is_failed(rcpt) |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
569 && !(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
|
570 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
|
571 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
572 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
573 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
|
574 msgout_cloned->rcpt_list = rcpt_list_non_delivered; |
0 | 575 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
576 if (!msgout_cloned->rcpt_list) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
577 destroy_msg_out(msgout_cloned); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
578 continue; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
579 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
580 |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
315
diff
changeset
|
581 /* filter by allowed envelope sender */ |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
315
diff
changeset
|
582 if (!route_sender_is_allowed(route, msgout->msg->return_path)) { |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
583 destroy_msg_out(msgout_cloned); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
584 continue; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
585 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
586 |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
315
diff
changeset
|
587 /* filter by allowed envelope rcpts */ |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
588 GList *rcpt_list_allowed = NULL; |
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
589 GList *rcpt_list_notallowed = NULL; |
370 | 590 route_split_rcpts(route, msgout_cloned->rcpt_list, |
591 &rcpt_list_allowed, &rcpt_list_notallowed); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
592 if (!rcpt_list_allowed) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
593 destroy_msg_out(msgout_cloned); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
594 continue; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
595 } |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
315
diff
changeset
|
596 |
370 | 597 logwrite(LOG_NOTICE, "%s using '%s'\n", msgout->msg->uid, |
598 route->name); | |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
599 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
600 g_list_free(msgout_cloned->rcpt_list); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
601 msgout_cloned->rcpt_list = rcpt_list_allowed; |
0 | 602 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
603 if (route->last_route) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
604 GList *rcpt_node; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
605 foreach(msgout_cloned->rcpt_list, rcpt_node) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
606 address *rcpt = (address *) (rcpt_node->data); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
607 rcpt->flags |= ADDR_FLAG_LAST_ROUTE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
608 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
609 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
610 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
611 route_prepare_msgout(route, msgout_cloned); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
612 msgout_list_deliver = g_list_append(msgout_list_deliver, msgout_cloned); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
613 } |
0 | 614 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
615 if (msgout_list_deliver) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
616 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
|
617 ok = TRUE; |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
618 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
619 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
|
620 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
621 return ok; |
0 | 622 } |
623 | |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
624 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
625 ** 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
|
626 ** to make sure that they will not be delivered again. |
0 | 627 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
628 void |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
629 update_non_rcpt_list(msg_out *msgout) |
0 | 630 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
631 GList *rcpt_node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
632 message *msg = msgout->msg; |
0 | 633 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
634 foreach(msgout->rcpt_list, rcpt_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
635 address *rcpt = (address *) (rcpt_node->data); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
636 if (addr_is_delivered(rcpt) || addr_is_failed(rcpt)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
637 msg->non_rcpt_list = g_list_append(msg->non_rcpt_list, rcpt); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
638 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
639 } |
0 | 640 } |
641 | |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
642 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
643 ** 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
|
644 ** 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
|
645 ** 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
|
646 ** 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
|
647 ** |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
648 ** returns TRUE if all went well. |
0 | 649 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
650 gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
651 deliver_finish(msg_out *msgout) |
0 | 652 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
653 GList *rcpt_node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
654 message *msg = msgout->msg; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
655 gboolean finished = TRUE; |
0 | 656 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
657 update_non_rcpt_list(msgout); |
0 | 658 |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
659 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
660 ** 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
|
661 ** 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
|
662 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
663 foreach(msg->rcpt_list, rcpt_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
664 address *rcpt = (address *) (rcpt_node->data); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
665 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
|
666 finished = FALSE; |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
667 } else { |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
668 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
669 ** 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
|
670 ** 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
|
671 ** 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
|
672 ** as well. |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
673 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
674 if (addr_is_delivered_children(rcpt)) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
675 addr_mark_delivered(rcpt); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
676 } else { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
677 addr_mark_failed(rcpt); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
678 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
679 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
680 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
681 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
682 if (finished) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
683 if (spool_delete_all(msg)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
684 logwrite(LOG_NOTICE, "%s completed.\n", msg->uid); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
685 return TRUE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
686 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
687 return FALSE; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
688 } |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
689 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
690 /* one not delivered address was found */ |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
691 if (!spool_write(msg, FALSE)) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
692 logwrite(LOG_ALERT, "could not write back spool header for %s\n", msg->uid); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
693 return FALSE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
694 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
695 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
696 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
|
697 return TRUE; |
0 | 698 } |
699 | |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
700 int |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
701 deliver_remote(GList *remote_msgout_list) |
0 | 702 { |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
703 int ok = TRUE; |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
704 GList *route_list = NULL; |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
705 GList *route_node; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
706 GList *rf_list = NULL; |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
707 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
|
708 |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
709 if (!remote_msgout_list) { |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
710 return FALSE; |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
711 } |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
712 |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
713 /* perma routes */ |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
714 if (conf.perma_routes) { |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
715 DEBUG(5) debugf("processing perma_routes\n"); |
0 | 716 |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
717 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
|
718 foreach(route_list, route_node) { |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
719 connect_route *route = (connect_route *) (route_node->data); |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
720 if (!deliver_route_msg_list(route, remote_msgout_list)) { |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
721 ok = FALSE; |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
722 } |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
723 } |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
724 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
|
725 } |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
726 |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
727 /* query routes */ |
310
f10a56dc7481
reworked online_detect to the simpler online_query
meillo@marmaro.de
parents:
280
diff
changeset
|
728 connect_name = online_query(); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
729 if (!connect_name) { |
344
0410c8aabac2
improved comments and debug messages
markus schnalke <meillo@marmaro.de>
parents:
343
diff
changeset
|
730 DEBUG(5) debugf("online query returned false\n"); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
731 return FALSE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
732 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
733 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
734 /* we are online! */ |
344
0410c8aabac2
improved comments and debug messages
markus schnalke <meillo@marmaro.de>
parents:
343
diff
changeset
|
735 DEBUG(5) debugf("processing query_routes\n"); |
0410c8aabac2
improved comments and debug messages
markus schnalke <meillo@marmaro.de>
parents:
343
diff
changeset
|
736 logwrite(LOG_NOTICE, "detected online configuration `%s'\n", connect_name); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
737 |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
738 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
|
739 if (!rf_list) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
740 logwrite(LOG_ALERT, "route list with name '%s' not found.\n", connect_name); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
741 return FALSE; |
0 | 742 } |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
743 |
321 | 744 route_list = read_route_list(rf_list, FALSE); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
745 if (!route_list) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
746 logwrite(LOG_ALERT, "could not read route list '%s'\n", connect_name); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
747 return FALSE; |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
748 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
749 |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
750 foreach(route_list, route_node) { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
751 connect_route *route = (connect_route *) (route_node->data); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
752 /* 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
|
753 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
|
754 } |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
755 destroy_route_list(route_list); |
344
0410c8aabac2
improved comments and debug messages
markus schnalke <meillo@marmaro.de>
parents:
343
diff
changeset
|
756 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
757 return ok; |
0 | 758 } |
759 | |
321 | 760 /* |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
761 ** 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
|
762 ** into local and remote addresses and processes them accordingly. |
321 | 763 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
764 gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
765 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
|
766 { |
343
9149d893eb52
refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents:
321
diff
changeset
|
767 GList *msgout_list = NULL; |
9149d893eb52
refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents:
321
diff
changeset
|
768 GList *msg_node; |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
769 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
|
770 GList *remote_msgout_list = NULL; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
771 GList *msgout_node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
772 GList *alias_table = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
773 gboolean ok = TRUE; |
0 | 774 |
343
9149d893eb52
refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents:
321
diff
changeset
|
775 /* create msgout_list */ |
9149d893eb52
refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents:
321
diff
changeset
|
776 foreach(msg_list, msg_node) { |
9149d893eb52
refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents:
321
diff
changeset
|
777 message *msg = (message *) msg_node->data; |
9149d893eb52
refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents:
321
diff
changeset
|
778 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
|
779 } |
9149d893eb52
refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents:
321
diff
changeset
|
780 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
781 if (conf.alias_file) { |
17
6c59dedd06be
fixed delivery with empty or non-existent alias file
meillo@marmaro.de
parents:
15
diff
changeset
|
782 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
|
783 } |
0 | 784 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
785 /* sort messages for different deliveries */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
786 foreach(msgout_list, msgout_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
787 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
|
788 GList *rcpt_list; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
789 GList *local_rcpt_list = NULL; |
237
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
224
diff
changeset
|
790 GList *other_rcpt_list = NULL; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
791 |
114 | 792 if (!spool_lock(msgout->msg->uid)) { |
793 DEBUG(5) debugf("spool_lock(%s) failed.\n", msgout->msg->uid); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
794 continue; |
114 | 795 } |
796 DEBUG(5) debugf("spool_lock(%s)\n", msgout->msg->uid); | |
0 | 797 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
798 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
|
799 if (conf.log_user) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
800 address *addr = create_address_qualified(conf.log_user, TRUE, conf.host_name); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
801 if (addr) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
802 rcpt_list = g_list_prepend(rcpt_list, addr); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
803 } else { |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
804 logwrite(LOG_ALERT, "invalid log_user address `%s', ignoring\n", conf.log_user); |
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
805 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
806 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
807 if (alias_table) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
808 GList *aliased_rcpt_list; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
809 aliased_rcpt_list = alias_expand(alias_table, rcpt_list, msgout->msg->non_rcpt_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
810 g_list_free(rcpt_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
811 rcpt_list = aliased_rcpt_list; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
812 } |
0 | 813 |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
814 /* split_rcpts(rcpt_list, NULL, &local_rcpt_list, NULL, &other_rcpt_list); */ |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
815 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
|
816 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
|
817 g_list_free(rcpt_list); |
0 | 818 |
237
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
224
diff
changeset
|
819 /* local recipients */ |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
224
diff
changeset
|
820 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
|
821 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
|
822 local_msgout->rcpt_list = local_rcpt_list; |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
224
diff
changeset
|
823 local_msgout_list = g_list_append(local_msgout_list, local_msgout); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
824 } |
0 | 825 |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
826 /* remote recipients, requires online delivery */ |
237
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
224
diff
changeset
|
827 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
|
828 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
|
829 remote_msgout->rcpt_list = other_rcpt_list; |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
830 remote_msgout_list = g_list_append(remote_msgout_list, remote_msgout); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
831 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
832 } |
0 | 833 |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
834 if (alias_table) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
835 destroy_table(alias_table); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
836 } |
0 | 837 |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
838 /* 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
|
839 |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
224
diff
changeset
|
840 if (local_msgout_list) { |
114 | 841 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
|
842 foreach(local_msgout_list, msgout_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
843 msg_out *msgout = (msg_out *) (msgout_node->data); |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
844 if (!deliver_local(msgout)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
845 ok = FALSE; |
280
72e377210d5e
heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
846 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
847 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
848 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
|
849 } |
0 | 850 |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
851 if (remote_msgout_list) { |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
350
diff
changeset
|
852 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
|
853 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
|
854 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
|
855 } |
0 | 856 |
344
0410c8aabac2
improved comments and debug messages
markus schnalke <meillo@marmaro.de>
parents:
343
diff
changeset
|
857 /* unlock spool files */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
858 foreach(msgout_list, msgout_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
859 msg_out *msgout = (msg_out *) (msgout_node->data); |
114 | 860 if (spool_unlock(msgout->msg->uid)) { |
861 DEBUG(5) debugf("spool_unlock(%s)\n", msgout->msg->uid); | |
862 } else { | |
863 DEBUG(5) debugf("spool_unlock(%s) failed.\n", msgout->msg->uid); | |
864 } | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
865 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
866 destroy_msg_out_list(msgout_list); |
0 | 867 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
868 return ok; |
0 | 869 } |
870 | |
321 | 871 /* |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
872 ** 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
|
873 ** (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
|
874 ** (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
|
875 ** deliver then. |
0 | 876 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
877 gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
354
diff
changeset
|
878 deliver(message *msg) |
0 | 879 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
880 gboolean ok; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
881 GList *msg_list = g_list_append(NULL, msg); |
0 | 882 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
883 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
|
884 g_list_free(msg_list); |
0 | 885 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
886 return ok; |
0 | 887 } |