annotate src/send_help.c @ 741:b72bcb7e08a2

Arbitrary headers in listtexts, fix default Content-Transfer-Encoding: header, and document \uNNNN substitution Also, the interface to prepstdreply() has changed; there is no longer a customheaders argument, which was never used anyway, and is now essentially redundant due to this patch.
author Ben Schmidt
date Mon, 20 Sep 2010 01:44:58 +1000
parents c26e97a2207b
children c3ee2bfaeb02
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
21ce01de8109 Initial revision
mmj
parents:
diff changeset
1 /* Copyright (C) 2003 Mads Martin Joergensen <mmj at mmj.dk>
21ce01de8109 Initial revision
mmj
parents:
diff changeset
2 *
21ce01de8109 Initial revision
mmj
parents:
diff changeset
3 * $Id$
21ce01de8109 Initial revision
mmj
parents:
diff changeset
4 *
225
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 189
diff changeset
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 189
diff changeset
6 * of this software and associated documentation files (the "Software"), to
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 189
diff changeset
7 * deal in the Software without restriction, including without limitation the
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 189
diff changeset
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 189
diff changeset
9 * sell copies of the Software, and to permit persons to whom the Software is
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 189
diff changeset
10 * furnished to do so, subject to the following conditions:
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 189
diff changeset
11 *
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 189
diff changeset
12 * The above copyright notice and this permission notice shall be included in
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 189
diff changeset
13 * all copies or substantial portions of the Software.
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 189
diff changeset
14 *
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 189
diff changeset
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 189
diff changeset
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 189
diff changeset
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 189
diff changeset
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 189
diff changeset
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 189
diff changeset
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 189
diff changeset
21 * IN THE SOFTWARE.
0
21ce01de8109 Initial revision
mmj
parents:
diff changeset
22 */
21ce01de8109 Initial revision
mmj
parents:
diff changeset
23
21ce01de8109 Initial revision
mmj
parents:
diff changeset
24 #include <stdio.h>
21ce01de8109 Initial revision
mmj
parents:
diff changeset
25 #include <stdlib.h>
21ce01de8109 Initial revision
mmj
parents:
diff changeset
26 #include <string.h>
25
65d01831c0eb log_error is it's own object now
mmj
parents: 18
diff changeset
27 #include <unistd.h>
171
f4051eb9504a Bye bye FILE*, welcome fd
mmj
parents: 130
diff changeset
28 #include <fcntl.h>
f4051eb9504a Bye bye FILE*, welcome fd
mmj
parents: 130
diff changeset
29 #include <sys/types.h>
f4051eb9504a Bye bye FILE*, welcome fd
mmj
parents: 130
diff changeset
30 #include <sys/stat.h>
0
21ce01de8109 Initial revision
mmj
parents:
diff changeset
31
21ce01de8109 Initial revision
mmj
parents:
diff changeset
32 #include "mlmmj.h"
21ce01de8109 Initial revision
mmj
parents:
diff changeset
33 #include "send_help.h"
21ce01de8109 Initial revision
mmj
parents:
diff changeset
34 #include "strgen.h"
21ce01de8109 Initial revision
mmj
parents:
diff changeset
35 #include "find_email_adr.h"
21ce01de8109 Initial revision
mmj
parents:
diff changeset
36 #include "getlistaddr.h"
520
734ce7aa42bb 1.2.9-RC1 with recipdelim patch
mmj
parents: 435
diff changeset
37 #include "getlistdelim.h"
25
65d01831c0eb log_error is it's own object now
mmj
parents: 18
diff changeset
38 #include "log_error.h"
171
f4051eb9504a Bye bye FILE*, welcome fd
mmj
parents: 130
diff changeset
39 #include "chomp.h"
f4051eb9504a Bye bye FILE*, welcome fd
mmj
parents: 130
diff changeset
40 #include "wrappers.h"
f4051eb9504a Bye bye FILE*, welcome fd
mmj
parents: 130
diff changeset
41 #include "mygetline.h"
189
cb46caab2621 New function to prepare a standard mail in an easy way, and make send_help
mmj
parents: 184
diff changeset
42 #include "prepstdreply.h"
245
00eadc106b34 changed to use the new memory wrappers
mortenp
parents: 225
diff changeset
43 #include "memory.h"
0
21ce01de8109 Initial revision
mmj
parents:
diff changeset
44
37
6b61ded65896 Send around the full path to the binaries
mmj
parents: 25
diff changeset
45 void send_help(const char *listdir, const char *emailaddr,
609
56785a0b38b6 changed send_help() to accept the name and textfile as arguments (Henne Vogelsang)
mortenp
parents: 553
diff changeset
46 const char *mlmmjsend, const char *name, const char *textfile)
0
21ce01de8109 Initial revision
mmj
parents:
diff changeset
47 {
520
734ce7aa42bb 1.2.9-RC1 with recipdelim patch
mmj
parents: 435
diff changeset
48 char *queuefilename, *listaddr, *listdelim, *listname, *listfqdn;
734ce7aa42bb 1.2.9-RC1 with recipdelim patch
mmj
parents: 435
diff changeset
49 char *fromaddr;
0
21ce01de8109 Initial revision
mmj
parents:
diff changeset
50
359
ca217febcfbd Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents: 312
diff changeset
51 listaddr = getlistaddr(listdir);
520
734ce7aa42bb 1.2.9-RC1 with recipdelim patch
mmj
parents: 435
diff changeset
52 listdelim = getlistdelim(listdir);
0
21ce01de8109 Initial revision
mmj
parents:
diff changeset
53 listname = genlistname(listaddr);
21ce01de8109 Initial revision
mmj
parents:
diff changeset
54 listfqdn = genlistfqdn(listaddr);
21ce01de8109 Initial revision
mmj
parents:
diff changeset
55
520
734ce7aa42bb 1.2.9-RC1 with recipdelim patch
mmj
parents: 435
diff changeset
56 fromaddr = concatstr(4, listname, listdelim, "bounces-help@", listfqdn);
734ce7aa42bb 1.2.9-RC1 with recipdelim patch
mmj
parents: 435
diff changeset
57 myfree(listdelim);
171
f4051eb9504a Bye bye FILE*, welcome fd
mmj
parents: 130
diff changeset
58
609
56785a0b38b6 changed send_help() to accept the name and textfile as arguments (Henne Vogelsang)
mortenp
parents: 553
diff changeset
59 queuefilename = prepstdreply(listdir, textfile, "$listowner$",
741
b72bcb7e08a2 Arbitrary headers in listtexts, fix default Content-Transfer-Encoding: header,
Ben Schmidt
parents: 660
diff changeset
60 emailaddr, NULL, 0, NULL, NULL);
189
cb46caab2621 New function to prepare a standard mail in an easy way, and make send_help
mmj
parents: 184
diff changeset
61 if(queuefilename == NULL) {
609
56785a0b38b6 changed send_help() to accept the name and textfile as arguments (Henne Vogelsang)
mortenp
parents: 553
diff changeset
62 log_error(LOG_ARGS, "Could not prepare %s mail", name);
171
f4051eb9504a Bye bye FILE*, welcome fd
mmj
parents: 130
diff changeset
63 exit(EXIT_FAILURE);
f4051eb9504a Bye bye FILE*, welcome fd
mmj
parents: 130
diff changeset
64 }
0
21ce01de8109 Initial revision
mmj
parents:
diff changeset
65
245
00eadc106b34 changed to use the new memory wrappers
mortenp
parents: 225
diff changeset
66 myfree(listaddr);
00eadc106b34 changed to use the new memory wrappers
mortenp
parents: 225
diff changeset
67 myfree(listname);
00eadc106b34 changed to use the new memory wrappers
mortenp
parents: 225
diff changeset
68 myfree(listfqdn);
0
21ce01de8109 Initial revision
mmj
parents:
diff changeset
69
37
6b61ded65896 Send around the full path to the binaries
mmj
parents: 25
diff changeset
70 execlp(mlmmjsend, mlmmjsend,
122
213b1e372027 It's not -L 1 but -l 1 for sending single mails
mmj
parents: 69
diff changeset
71 "-l", "1",
529
d65b467b647d Pass on listdir to mlmmjsend so we can get the smtpport and relayhost also
mmj
parents: 520
diff changeset
72 "-L", listdir,
0
21ce01de8109 Initial revision
mmj
parents:
diff changeset
73 "-T", emailaddr,
21ce01de8109 Initial revision
mmj
parents:
diff changeset
74 "-F", fromaddr,
435
65781b43a7b9 - subswitch, NULL);
mmj
parents: 359
diff changeset
75 "-m", queuefilename, (char *)NULL);
189
cb46caab2621 New function to prepare a standard mail in an easy way, and make send_help
mmj
parents: 184
diff changeset
76
39
3509e8837988 changed log_error() to be a function (no C99 here)
mortenp
parents: 37
diff changeset
77 log_error(LOG_ARGS, "execlp() of '%s' failed", mlmmjsend);
0
21ce01de8109 Initial revision
mmj
parents:
diff changeset
78 exit(EXIT_FAILURE);
21ce01de8109 Initial revision
mmj
parents:
diff changeset
79 }