Commit 8ad47471 8ad474712f6758cdff637c5391867706957dfd74 by Sergey Poznyakoff

Implement --attach option in mail; fix dead.letter functionality

* NEWS: Update.
* doc/imprimatur: Upgrade.
* libmailutils/mime/attachment.c (mu_message_create_attachment): Bugfixes.
* mail/mail.c: New options --attach, --content-type and
--encoding.
* mail/mail.h (default_encoding, default_content_type): New externs.
(send_attach_file): New proto.
* mail/send.c (send_attach_file): New function.
(save_dead_message_env): New function.
(save_dead_message): Rewrite.
(mail_send0): Attach files, if requested.
1 parent ca45a7aa
GNU mailutils NEWS -- history of user-visible changes. 2012-06-07
GNU mailutils NEWS -- history of user-visible changes. 2012-07-18
Copyright (C) 2002-2012 Free Software Foundation, Inc.
See the end of file for copying conditions.
......@@ -82,7 +82,7 @@ are not used to avoid compromising security.
See <http://mailutils.org/wiki/debug_level>.
** Imap4d undergone a lot of changes to comply to existing RFCs
** Imap4d underwent a lot of changes to comply to existing RFCs
** Pop3d and imap4d allow for mailbox-independent compulsory locking
......@@ -114,6 +114,27 @@ header field with the given date.
See <http://mailutils.org/wiki/Timestamp_(Sieve_test)>.
** mail: sending attachments
The mail[x] utility now allows for sending attachments. Any number of
files can be attached to the composed letter by using the `--attach'
(`-A') options. The files will be attached in the same order in which
they appear in the command line. By default, each attachment is
assigned the content type "application/octet-stream" and is encoded
using Base64. This can be changed using the `--content-type' and
`--encoding' options. These options affect all attachments that
appear after them in the command line, until next occurrence of the
same option or end of command line, whichever occurs first. For
example:
mail -A prog --encoding quoted-printable --content-type text/c \
-A main.c -A ext.h
Here, the file "prog" will be attached witg the content type
"application/octet-stream" and encoding base64, while the files
"main.c" and "ext.h" will be marked with content type "text/c" and
encoded using "quoted-printable" algorithm.
** MH: improved compatibility with other implementations
** MH inc: new option --moveto
......@@ -181,12 +202,29 @@ imap4d, pop3d, comsat) will be built. Its counterpart,
`--enable-build-clients' controls whether client utilities will be
built.
The effect of both options is overridden by the `--enable-build-*'
options for particular components. For example, to build only
the "mail" utility:
./configure --disable-build-clients --enable-build-mail
** The --with-mailbindir option
This option changes installation directory for the "mail" utility.
** DBM options
It is normally not needed to specify --with-gdbm, --with-berkeley-db
or --with-ndbm explicitly. Configuration will automatically pick up
all available DBM libraries it can use.
The option `--with-dbm' can be used to enable or disable building of
all available DBM interfaces. Its effect is overridden by `--with-*'
options for particular interfaces. For example, to build only GDBM
(even if another databases are supported by the system):
./configure --without-dbm --with-gdbm
** Nntp client is not yet implemented
** Link with GSASL by default
......
imprimatur @ f32ef198
Subproject commit 04255b6d5551952b4e0c94da15988f573e3e9fc4
Subproject commit f32ef1983968e755cd580b06e369476d7e7f88b6
......
......@@ -88,12 +88,15 @@ mu_message_create_attachment (const char *content_type, const char *encoding,
"Content-Transfer-Encoding: %s\n"
"Content-Disposition: attachment; filename=%s\n\n",
content_type, name, encoding, name);
if (ret)
if (ret == 0)
{
if ((ret = mu_header_create (&hdr, header,
strlen (header))) == 0)
{
mu_stream_t bstr;
mu_message_get_body (*newmsg, &body);
mu_body_get_streamref (body, &bstr);
if ((ret = mu_file_stream_create (&fstream, filename,
MU_STREAM_READ)) == 0)
{
......@@ -101,10 +104,12 @@ mu_message_create_attachment (const char *content_type, const char *encoding,
MU_FILTER_ENCODE,
MU_STREAM_READ)) == 0)
{
mu_body_set_stream (body, tstream, *newmsg);
mu_stream_copy (bstr, tstream, 0, NULL);
mu_stream_unref (tstream);
mu_message_set_header (*newmsg, hdr, NULL);
}
}
mu_stream_unref (bstr);
free (header);
}
}
......
......@@ -31,7 +31,9 @@ static char doc[] = N_("GNU mail -- process mail messages.\n"
"by the first argument, or the user's mbox, if no argument given.\n");
static char args_doc[] = N_("[address...]\n-f [OPTION...] [file]\n--file [OPTION...] [file]\n--file=file [OPTION...]");
#define F_OPTION 256
#define F_OPTION 256
#define F_ENCODING 257
#define F_CONTENT_TYPE 258
static struct argp_option options[] = {
{ NULL, 'f', NULL, OPTION_HIDDEN, NULL, 0 },
......@@ -57,6 +59,12 @@ static struct argp_option options[] = {
N_("append given header to the message being sent"), 0},
{"exec", 'E', N_("COMMAND"), 0,
N_("execute COMMAND"), 0 },
{"encoding", F_ENCODING, N_("NAME"), 0,
N_("set encoding for subsequent --attach options"), 0 },
{"content-type", F_CONTENT_TYPE, N_("TYPE"), 0,
N_("set content type for subsequent --attach options"), 0 },
{"attach", 'A', N_("FILE"), 0,
N_("attach FILE"), 0 },
{ NULL, 0, NULL, 0, NULL, 0 }
};
......@@ -84,6 +92,17 @@ parse_opt (int key, char *arg, struct argp_state *state)
args->hint |= HINT_SEND_MODE;
send_append_header (arg);
break;
case 'A':
args->hint |= HINT_SEND_MODE;
if (send_attach_file (arg))
exit (1);
break;
case F_CONTENT_TYPE:
free (default_content_type);
default_content_type = mu_strdup (arg);
break;
case 'e':
util_cache_command (&command_list, "setq mode=exist");
......@@ -139,6 +158,11 @@ parse_opt (int key, char *arg, struct argp_state *state)
case 'E':
util_cache_command (&command_list, "%s", arg);
break;
case F_ENCODING:
free (default_encoding);
default_encoding = mu_strdup (arg);
break;
case 'F':
util_cache_command (&command_list, "set byname");
......
......@@ -171,6 +171,8 @@ extern mu_mailbox_t mbox;
extern size_t total;
extern int interactive;
extern const char *program_version;
extern char *default_encoding;
extern char *default_content_type;
/* Functions */
extern int mail_alias (int argc, char **argv);
......@@ -256,6 +258,7 @@ extern char *mail_expand_name (const char *name);
extern void send_append_header (char *text);
extern void send_append_header2 (char *name, char *value, int mode);
extern int send_attach_file (const char *name);
extern int escape_shell (int argc, char **argv, compose_env_t *env);
extern int escape_command (int argc, char **argv, compose_env_t *env);
......