(read_mts_profile): Support localname and localdomain
variables. (read_mts_profile): Support x-mailer variable.
Showing
1 changed file
with
57 additions
and
14 deletions
... | @@ -32,7 +32,6 @@ Options marked with `*' are not yet implemented.\n\ | ... | @@ -32,7 +32,6 @@ Options marked with `*' are not yet implemented.\n\ |
32 | Use -help to obtain the list of traditional MH options."); | 32 | Use -help to obtain the list of traditional MH options."); |
33 | static char args_doc[] = N_("file [file...]"); | 33 | static char args_doc[] = N_("file [file...]"); |
34 | 34 | ||
35 | |||
36 | /* GNU options */ | 35 | /* GNU options */ |
37 | static struct argp_option options[] = { | 36 | static struct argp_option options[] = { |
38 | {"alias", ARG_ALIAS, N_("FILE"), 0, | 37 | {"alias", ARG_ALIAS, N_("FILE"), 0, |
... | @@ -117,6 +116,8 @@ static int verbose; /* Produce verbose diagnostics */ | ... | @@ -117,6 +116,8 @@ static int verbose; /* Produce verbose diagnostics */ |
117 | static int watch; /* Watch the delivery process */ | 116 | static int watch; /* Watch the delivery process */ |
118 | static unsigned width = 76; /* Maximum width of header fields */ | 117 | static unsigned width = 76; /* Maximum width of header fields */ |
119 | 118 | ||
119 | #define DEFAULT_X_MAILER "MH (" PACKAGE_STRING ")" | ||
120 | |||
120 | #define WATCH(c) do {\ | 121 | #define WATCH(c) do {\ |
121 | if (watch)\ | 122 | if (watch)\ |
122 | watch_printf c;\ | 123 | watch_printf c;\ |
... | @@ -156,7 +157,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) | ... | @@ -156,7 +157,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
156 | return 1; | 157 | return 1; |
157 | 158 | ||
158 | case ARG_FORMAT: | 159 | case ARG_FORMAT: |
159 | reformat_recipients = is_true(arg); | 160 | reformat_recipients = is_true (arg); |
160 | break; | 161 | break; |
161 | 162 | ||
162 | case ARG_NOFORMAT: | 163 | case ARG_NOFORMAT: |
... | @@ -164,7 +165,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) | ... | @@ -164,7 +165,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
164 | break; | 165 | break; |
165 | 166 | ||
166 | case ARG_FORWARD: | 167 | case ARG_FORWARD: |
167 | forward_notice = is_true(arg); | 168 | forward_notice = is_true (arg); |
168 | break; | 169 | break; |
169 | 170 | ||
170 | case ARG_NOFORWARD: | 171 | case ARG_NOFORWARD: |
... | @@ -172,7 +173,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) | ... | @@ -172,7 +173,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
172 | break; | 173 | break; |
173 | 174 | ||
174 | case ARG_MIME: | 175 | case ARG_MIME: |
175 | mime_encaps = is_true(arg); | 176 | mime_encaps = is_true (arg); |
176 | break; | 177 | break; |
177 | 178 | ||
178 | case ARG_NOMIME: | 179 | case ARG_NOMIME: |
... | @@ -180,7 +181,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) | ... | @@ -180,7 +181,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
180 | break; | 181 | break; |
181 | 182 | ||
182 | case ARG_MSGID: | 183 | case ARG_MSGID: |
183 | append_msgid = is_true(arg); | 184 | append_msgid = is_true (arg); |
184 | break; | 185 | break; |
185 | 186 | ||
186 | case ARG_NOMSGID: | 187 | case ARG_NOMSGID: |
... | @@ -188,7 +189,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) | ... | @@ -188,7 +189,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
188 | break; | 189 | break; |
189 | 190 | ||
190 | case ARG_PUSH: | 191 | case ARG_PUSH: |
191 | background = is_true(arg); | 192 | background = is_true (arg); |
192 | break; | 193 | break; |
193 | 194 | ||
194 | case ARG_NOPUSH: | 195 | case ARG_NOPUSH: |
... | @@ -197,7 +198,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) | ... | @@ -197,7 +198,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
197 | 198 | ||
198 | case ARG_SPLIT: | 199 | case ARG_SPLIT: |
199 | split_message = 1; | 200 | split_message = 1; |
200 | split_interval = strtoul(arg, &p, 10); | 201 | split_interval = strtoul (arg, &p, 10); |
201 | if (*p) | 202 | if (*p) |
202 | { | 203 | { |
203 | argp_error (state, _("Invalid number")); | 204 | argp_error (state, _("Invalid number")); |
... | @@ -206,7 +207,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) | ... | @@ -206,7 +207,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
206 | break; | 207 | break; |
207 | 208 | ||
208 | case ARG_VERBOSE: | 209 | case ARG_VERBOSE: |
209 | verbose = is_true(arg); | 210 | verbose = is_true (arg); |
210 | break; | 211 | break; |
211 | 212 | ||
212 | case ARG_NOVERBOSE: | 213 | case ARG_NOVERBOSE: |
... | @@ -214,7 +215,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) | ... | @@ -214,7 +215,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
214 | break; | 215 | break; |
215 | 216 | ||
216 | case ARG_WATCH: | 217 | case ARG_WATCH: |
217 | watch = is_true(arg); | 218 | watch = is_true (arg); |
218 | break; | 219 | break; |
219 | 220 | ||
220 | case ARG_NOWATCH: | 221 | case ARG_NOWATCH: |
... | @@ -222,7 +223,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) | ... | @@ -222,7 +223,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
222 | break; | 223 | break; |
223 | 224 | ||
224 | case ARG_WIDTH: | 225 | case ARG_WIDTH: |
225 | width = strtoul(arg, &p, 10); | 226 | width = strtoul (arg, &p, 10); |
226 | if (*p) | 227 | if (*p) |
227 | { | 228 | { |
228 | argp_error (state, _("Invalid number")); | 229 | argp_error (state, _("Invalid number")); |
... | @@ -275,6 +276,8 @@ void | ... | @@ -275,6 +276,8 @@ void |
275 | read_mts_profile () | 276 | read_mts_profile () |
276 | { | 277 | { |
277 | char *p; | 278 | char *p; |
279 | char *hostname = NULL; | ||
280 | int rc; | ||
278 | mh_context_t *local_profile; | 281 | mh_context_t *local_profile; |
279 | 282 | ||
280 | p = mh_expand_name (MHLIBDIR, "mtstailor", 0); | 283 | p = mh_expand_name (MHLIBDIR, "mtstailor", 0); |
... | @@ -286,6 +289,35 @@ read_mts_profile () | ... | @@ -286,6 +289,35 @@ read_mts_profile () |
286 | if (mh_context_read (local_profile) == 0) | 289 | if (mh_context_read (local_profile) == 0) |
287 | mh_context_merge (mts_profile, local_profile); | 290 | mh_context_merge (mts_profile, local_profile); |
288 | mh_context_destroy (&local_profile); | 291 | mh_context_destroy (&local_profile); |
292 | |||
293 | if ((p = mh_context_get_value (mts_profile, "localname", NULL))) | ||
294 | { | ||
295 | hostname = p; | ||
296 | mu_set_user_email_domain (p); | ||
297 | } | ||
298 | else if ((rc = mu_get_host_name (&hostname))) | ||
299 | mu_error (_("Cannot get system host name: %s"), mu_strerror (rc)); | ||
300 | |||
301 | if ((p = mh_context_get_value (mts_profile, "localdomain", NULL))) | ||
302 | { | ||
303 | const char *domain; | ||
304 | char *newdomain; | ||
305 | |||
306 | if (!hostname) | ||
307 | exit (1); | ||
308 | |||
309 | newdomain = xmalloc (strlen (hostname) + 1 + strlen (p) + 1); | ||
310 | strcpy (newdomain, hostname); | ||
311 | strcat (newdomain, "."); | ||
312 | strcat (newdomain, p); | ||
313 | rc = mu_set_user_email_domain (newdomain); | ||
314 | free (newdomain); | ||
315 | if (rc) | ||
316 | { | ||
317 | mu_error (_("Cannot set user mail domain: %s"), mu_strerror (rc)); | ||
318 | exit (1); | ||
319 | } | ||
320 | } | ||
289 | } | 321 | } |
290 | 322 | ||
291 | 323 | ||
... | @@ -302,7 +334,7 @@ open_mailer () | ... | @@ -302,7 +334,7 @@ open_mailer () |
302 | status = mu_mailer_create (&mailer, url); | 334 | status = mu_mailer_create (&mailer, url); |
303 | if (status) | 335 | if (status) |
304 | { | 336 | { |
305 | mh_error(_("Cannot create mailer `%s'"), url); | 337 | mh_error (_("Cannot create mailer `%s'"), url); |
306 | return NULL; | 338 | return NULL; |
307 | } | 339 | } |
308 | 340 | ||
... | @@ -317,7 +349,7 @@ open_mailer () | ... | @@ -317,7 +349,7 @@ open_mailer () |
317 | status = mu_mailer_open (mailer, MU_STREAM_RDWR); | 349 | status = mu_mailer_open (mailer, MU_STREAM_RDWR); |
318 | if (status) | 350 | if (status) |
319 | { | 351 | { |
320 | mh_error(_("Cannot open mailer `%s'"), url); | 352 | mh_error (_("Cannot open mailer `%s'"), url); |
321 | return NULL; | 353 | return NULL; |
322 | } | 354 | } |
323 | return mailer; | 355 | return mailer; |
... | @@ -448,8 +480,19 @@ _action_send (void *item, void *data) | ... | @@ -448,8 +480,19 @@ _action_send (void *item, void *data) |
448 | if (append_msgid | 480 | if (append_msgid |
449 | && mu_header_get_value (hdr, MU_HEADER_MESSAGE_ID, NULL, 0, &n)) | 481 | && mu_header_get_value (hdr, MU_HEADER_MESSAGE_ID, NULL, 0, &n)) |
450 | create_message_id (hdr); | 482 | create_message_id (hdr); |
451 | } | ||
452 | 483 | ||
484 | if (mu_header_get_value (hdr, MU_HEADER_X_MAILER, NULL, 0, &n)) | ||
485 | { | ||
486 | char *p = mh_context_get_value (mts_profile, "x-mailer", "yes"); | ||
487 | |||
488 | if (!strcmp (p, "yes")) | ||
489 | mu_header_set_value (hdr, MU_HEADER_X_MAILER, | ||
490 | DEFAULT_X_MAILER, 0); | ||
491 | else if (strcmp (p, "no")) | ||
492 | mu_header_set_value (hdr, MU_HEADER_X_MAILER, p, 0); | ||
493 | } | ||
494 | } | ||
495 | |||
453 | expand_aliases (msg); | 496 | expand_aliases (msg); |
454 | fix_fcc (msg); | 497 | fix_fcc (msg); |
455 | 498 | ||
... | @@ -539,5 +582,5 @@ main (int argc, char **argv) | ... | @@ -539,5 +582,5 @@ main (int argc, char **argv) |
539 | argc = 1; | 582 | argc = 1; |
540 | } | 583 | } |
541 | 584 | ||
542 | return send(argc, argv); | 585 | return send (argc, argv); |
543 | } | 586 | } | ... | ... |
-
Please register or sign in to post a comment