aboutsummaryrefslogtreecommitdiff
path: root/mailutils
diff options
context:
space:
mode:
Diffstat (limited to 'mailutils')
-rw-r--r--mailutils/mail.c2
-rw-r--r--mailutils/mail.h7
-rw-r--r--mailutils/makemime.c34
-rw-r--r--mailutils/reformime.c1
-rw-r--r--mailutils/sendmail.c22
5 files changed, 41 insertions, 25 deletions
diff --git a/mailutils/mail.c b/mailutils/mail.c
index f5260d9db..199f64407 100644
--- a/mailutils/mail.c
+++ b/mailutils/mail.c
@@ -119,7 +119,7 @@ static char* FAST_FUNC parse_url(char *url, char **user, char **pass)
119void FAST_FUNC encode_base64(char *fname, const char *text, const char *eol) 119void FAST_FUNC encode_base64(char *fname, const char *text, const char *eol)
120{ 120{
121 enum { 121 enum {
122 SRC_BUF_SIZE = 45, /* This *MUST* be a multiple of 3 */ 122 SRC_BUF_SIZE = 57, /* This *MUST* be a multiple of 3 */
123 DST_BUF_SIZE = 4 * ((SRC_BUF_SIZE + 2) / 3), 123 DST_BUF_SIZE = 4 * ((SRC_BUF_SIZE + 2) / 3),
124 }; 124 };
125#define src_buf text 125#define src_buf text
diff --git a/mailutils/mail.h b/mailutils/mail.h
index d1d783055..fa0c5b378 100644
--- a/mailutils/mail.h
+++ b/mailutils/mail.h
@@ -16,22 +16,15 @@ struct globals {
16 char *pass; 16 char *pass;
17 FILE *fp0; // initial stdin 17 FILE *fp0; // initial stdin
18 char *opt_charset; 18 char *opt_charset;
19 char *content_type;
20}; 19};
21 20
22#define G (*ptr_to_globals) 21#define G (*ptr_to_globals)
23#define timeout (G.timeout ) 22#define timeout (G.timeout )
24#define verbose (G.verbose ) 23#define verbose (G.verbose )
25#define opts (G.opts ) 24#define opts (G.opts )
26//#define user (G.user )
27//#define pass (G.pass )
28//#define fp0 (G.fp0 )
29//#define opt_charset (G.opt_charset)
30//#define content_type (G.content_type)
31#define INIT_G() do { \ 25#define INIT_G() do { \
32 SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ 26 SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
33 G.opt_charset = (char *)CONFIG_FEATURE_MIME_CHARSET; \ 27 G.opt_charset = (char *)CONFIG_FEATURE_MIME_CHARSET; \
34 G.content_type = (char *)"text/plain"; \
35} while (0) 28} while (0)
36 29
37//char FAST_FUNC *parse_url(char *url, char **user, char **pass); 30//char FAST_FUNC *parse_url(char *url, char **user, char **pass);
diff --git a/mailutils/makemime.c b/mailutils/makemime.c
index a9ff03d03..4b07e54de 100644
--- a/mailutils/makemime.c
+++ b/mailutils/makemime.c
@@ -1,7 +1,6 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * makemime: create MIME-encoded message 3 * makemime: create MIME-encoded message
4 * reformime: parse MIME-encoded message
5 * 4 *
6 * Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com> 5 * Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com>
7 * 6 *
@@ -135,19 +134,42 @@ Content-Transfer-Encoding: 7bit
135//usage: "\n -o FILE Output. Default: stdout" 134//usage: "\n -o FILE Output. Default: stdout"
136//usage: "\n -a HDR Add header. Examples:" 135//usage: "\n -a HDR Add header. Examples:"
137//usage: "\n \"From: user@host.org\", \"Date: `date -R`\"" 136//usage: "\n \"From: user@host.org\", \"Date: `date -R`\""
138//usage: "\n -c CT Content type. Default: text/plain" 137//usage: "\n -c CT Content type. Default: application/octet-stream"
139//usage: "\n -C CS Charset. Default: " CONFIG_FEATURE_MIME_CHARSET 138//usage: "\n -C CS Charset. Default: " CONFIG_FEATURE_MIME_CHARSET
140/* //usage: "\n -e ENC Transfer encoding. Ignored. base64 is assumed" */ 139/* //usage: "\n -e ENC Transfer encoding. Ignored. base64 is assumed" */
141//usage: "\n" 140//usage: "\n"
142//usage: "\nOther options are silently ignored" 141//usage: "\nOther options are silently ignored"
143 142
143/*
144 * -c [Content-Type] should create just one MIME section
145 * with "Content-Type:", "Content-Transfer-Encoding:", and HDR from "-a HDR".
146 * NB: without "Content-Disposition:" auto-added, unlike we do now
147 * NB2: -c has *optional* param which nevertheless _can_ be specified after a space :(
148 *
149 * -m [multipart/mixed] should create multipart MIME section
150 * with "Content-Type:", "Content-Transfer-Encoding:", and HDR from "-a HDR",
151 * and add FILE to it _verbatim_:
152 * HEADERS
153 *
154 * --=_1_1321709112_1605
155 * FILE_CONTENTS
156 * --=_1_1321709112_1605
157 * without any encoding of FILE_CONTENTS. (Basically, it expects that FILE
158 * is the result of "makemime -c").
159 *
160 * -j MULTIPART_FILE1 SINGLE_FILE2 should output MULTIPART_FILE1 + SINGLE_FILE2
161 *
162 * Our current behavior is a mutant "-m + -c + -j" one: we create multipart MIME
163 * and we put "-c" encoded FILEs into many multipart sections.
164 */
165
144int makemime_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 166int makemime_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
145int makemime_main(int argc UNUSED_PARAM, char **argv) 167int makemime_main(int argc UNUSED_PARAM, char **argv)
146{ 168{
147 llist_t *opt_headers = NULL, *l; 169 llist_t *opt_headers = NULL, *l;
148 const char *opt_output; 170 const char *opt_output;
171 const char *content_type = "application/octet-stream";
149#define boundary opt_output 172#define boundary opt_output
150
151 enum { 173 enum {
152 OPT_c = 1 << 0, // create (non-multipart) section 174 OPT_c = 1 << 0, // create (non-multipart) section
153 OPT_e = 1 << 1, // Content-Transfer-Encoding. Ignored. Assumed base64 175 OPT_e = 1 << 1, // Content-Transfer-Encoding. Ignored. Assumed base64
@@ -164,8 +186,8 @@ int makemime_main(int argc UNUSED_PARAM, char **argv)
164 // parse options 186 // parse options
165 opt_complementary = "a::"; 187 opt_complementary = "a::";
166 opts = getopt32(argv, 188 opts = getopt32(argv,
167 "c:e:o:C:N:a:", //:m:j:", 189 "c:e:o:C:N:a:", // "m:j:",
168 &G.content_type, NULL, &opt_output, &G.opt_charset, NULL, &opt_headers //, NULL, NULL 190 &content_type, NULL, &opt_output, &G.opt_charset, NULL, &opt_headers //, NULL, NULL
169 ); 191 );
170 //argc -= optind; 192 //argc -= optind;
171 argv += optind; 193 argv += optind;
@@ -202,7 +224,7 @@ int makemime_main(int argc UNUSED_PARAM, char **argv)
202 "Content-Disposition: inline; filename=\"%s\"\n" 224 "Content-Disposition: inline; filename=\"%s\"\n"
203 "Content-Transfer-Encoding: base64\n" 225 "Content-Transfer-Encoding: base64\n"
204 , boundary 226 , boundary
205 , G.content_type 227 , content_type
206 , G.opt_charset 228 , G.opt_charset
207 , bb_get_last_path_component_strip(*argv) 229 , bb_get_last_path_component_strip(*argv)
208 ); 230 );
diff --git a/mailutils/reformime.c b/mailutils/reformime.c
index 5e28ef729..8e7d455f6 100644
--- a/mailutils/reformime.c
+++ b/mailutils/reformime.c
@@ -1,6 +1,5 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * makemime: create MIME-encoded message
4 * reformime: parse MIME-encoded message 3 * reformime: parse MIME-encoded message
5 * 4 *
6 * Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com> 5 * Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com>
diff --git a/mailutils/sendmail.c b/mailutils/sendmail.c
index dbd491002..aa381c60f 100644
--- a/mailutils/sendmail.c
+++ b/mailutils/sendmail.c
@@ -281,17 +281,19 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv)
281 281
282 // analyze headers 282 // analyze headers
283 // To: or Cc: headers add recipients 283 // To: or Cc: headers add recipients
284 if (0 == strncasecmp("To:", s, 3) || 0 == strncasecmp("Bcc:" + 1, s, 3)) { 284 if (opts & OPT_t) {
285 rcptto(sane_address(s+3)); 285 if (0 == strncasecmp("To:", s, 3) || 0 == strncasecmp("Bcc:" + 1, s, 3)) {
286 goto addheader; 286 rcptto(sane_address(s+3));
287 goto addheader;
288 }
289 // Bcc: header adds blind copy (hidden) recipient
290 if (0 == strncasecmp("Bcc:", s, 4)) {
291 rcptto(sane_address(s+4));
292 free(s);
293 continue; // N.B. Bcc: vanishes from headers!
294 }
287 } 295 }
288 // Bcc: header adds blind copy (hidden) recipient 296 if (strchr(s, ':') || (list && isspace(s[0]))) {
289 if (0 == strncasecmp("Bcc:", s, 4)) {
290 rcptto(sane_address(s+4));
291 free(s);
292 // N.B. Bcc: vanishes from headers!
293 } else
294 if (strchr(s, ':') || (list && skip_whitespace(s) != s)) {
295 // other headers go verbatim 297 // other headers go verbatim
296 // N.B. RFC2822 2.2.3 "Long Header Fields" allows for headers to occupy several lines. 298 // N.B. RFC2822 2.2.3 "Long Header Fields" allows for headers to occupy several lines.
297 // Continuation is denoted by prefixing additional lines with whitespace(s). 299 // Continuation is denoted by prefixing additional lines with whitespace(s).