[PATCH 1 of 2] Add sendbox support to normal send path
# HG changeset patch
# User agriffis@xxxxxxxxxxxxxxx
# Date 1155133833 14400
# Node ID 68b578d136acaa26471c0cf6c3d405c13142dfea
# Parent b9caff41ea4eaa76eef9532ffe1bb33114cb9c97
Add sendbox support to normal send path
diff -r b9caff41ea4e -r 68b578d136ac compose.c
--- a/compose.c Wed Aug 09 10:26:01 2006 -0400
+++ b/compose.c Wed Aug 09 10:30:33 2006 -0400
@@ -1207,7 +1207,7 @@ int mutt_compose_menu (HEADER *msg, /*
if (msg->content->next)
msg->content = mutt_make_multipart (msg->content);
- if (mutt_write_fcc (NONULL (fname), msg, NULL, 1, NULL) < 0)
+ if (mutt_write_fcc (NONULL (fname), msg, NULL, 1, NULL, 0) < 0)
msg->content = mutt_remove_multipart (msg->content);
else
mutt_message _("Message written.");
diff -r b9caff41ea4e -r 68b578d136ac globals.h
--- a/globals.h Wed Aug 09 10:26:01 2006 -0400
+++ b/globals.h Wed Aug 09 10:30:33 2006 -0400
@@ -110,6 +110,7 @@ WHERE char *PrintCmd;
WHERE char *PrintCmd;
WHERE char *QueryCmd;
WHERE char *Realname;
+WHERE char *Sendbox;
WHERE char *SendCharset;
WHERE char *Sendmail;
WHERE char *Shell;
diff -r b9caff41ea4e -r 68b578d136ac init.h
--- a/init.h Wed Aug 09 10:26:01 2006 -0400
+++ b/init.h Wed Aug 09 10:30:33 2006 -0400
@@ -2450,12 +2450,23 @@ struct option_t MuttVars[] = {
** iso-8859-2, koi8-r or iso-2022-jp) either instead of or after
** "iso-8859-1".
*/
+ { "sendbox", DT_PATH, R_NONE, UL &Sendbox, 0 },
+ /*
+ ** .pp
+ ** Specifies a special mailbox that will
+ ** \fBsend\fP mail when written, honored when \fIuse_sendbox\fB is \fIset\fP.
+ ** To make use of this, you probably want a Courier IMAP server configured
for
+ ** sending, see
+ ** http://www.inter7.com/courierimap/INSTALL.html#imapsend
+ */
{ "sendmail", DT_PATH, R_NONE, UL &Sendmail, UL SENDMAIL "
-oem -oi" },
/*
** .pp
** Specifies the program and arguments used to deliver mail sent by Mutt.
** Mutt expects that the specified program interprets additional
** arguments as recipient addresses.
+ ** .pp
+ ** This variable is ignored in favor of \fIsendbox\fP if \fIuse_sendbox\fP
is \fIset\fP.
*/
{ "sendmail_wait", DT_NUM, R_NONE, UL &SendmailWait, 0 },
/*
@@ -2877,6 +2888,12 @@ struct option_t MuttVars[] = {
** Normally, the default should work.
*/
#endif /* HAVE_GETADDRINFO */
+ { "use_sendbox", DT_BOOL, R_NONE, OPTUSESENDBOX, 0 },
+ /*
+ ** .pp
+ ** When \fIset\P, mutt sends mail using \fIsendbox\fB instead
+ ** of \fIsendmail\fP.
+ */
{ "user_agent", DT_BOOL, R_NONE, OPTXMAILER, 1},
/*
** .pp
diff -r b9caff41ea4e -r 68b578d136ac mutt.h
--- a/mutt.h Wed Aug 09 10:26:01 2006 -0400
+++ b/mutt.h Wed Aug 09 10:30:33 2006 -0400
@@ -442,6 +442,7 @@ enum
#ifdef HAVE_GETADDRINFO
OPTUSEIPV6,
#endif
+ OPTUSESENDBOX,
OPTWAITKEY,
OPTWEED,
OPTWRAP,
diff -r b9caff41ea4e -r 68b578d136ac mx.c
--- a/mx.c Wed Aug 09 10:26:01 2006 -0400
+++ b/mx.c Wed Aug 09 10:30:33 2006 -0400
@@ -153,7 +153,7 @@ int mx_lock_file (const char *path, int
#if defined (USE_FCNTL) || defined (USE_FLOCK)
int count;
int attempt;
- struct stat prev_sb;
+ struct stat prev_sb = { 0 }; /* silence gcc warnings */
#endif
int r = 0;
@@ -166,7 +166,6 @@ int mx_lock_file (const char *path, int
count = 0;
attempt = 0;
- prev_sb.st_size = 0; /* silence a GCC warning */
while (fcntl (fd, F_SETLK, &lck) == -1)
{
struct stat sb;
diff -r b9caff41ea4e -r 68b578d136ac protos.h
--- a/protos.h Wed Aug 09 10:26:01 2006 -0400
+++ b/protos.h Wed Aug 09 10:30:33 2006 -0400
@@ -353,7 +353,7 @@ void mutt_update_num_postponed (void);
void mutt_update_num_postponed (void);
int mutt_wait_filter (pid_t);
int mutt_which_case (const char *);
-int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int,
char *);
+int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int,
char *, int);
int mutt_write_mime_body (BODY *, FILE *);
int mutt_write_mime_header (BODY *, FILE *);
int mutt_write_rfc822_header (FILE *, ENVELOPE *, BODY *, int, int);
diff -r b9caff41ea4e -r 68b578d136ac send.c
--- a/send.c Wed Aug 09 10:26:01 2006 -0400
+++ b/send.c Wed Aug 09 10:30:33 2006 -0400
@@ -962,7 +962,13 @@ static int send_message (HEADER *msg)
char tempfile[_POSIX_PATH_MAX];
FILE *tempfp;
int i;
-
+
+ /* Some IMAP servers (e.g. Courier) allow sending mail by saving to a special
+ * folder, see http://www.inter7.com/courierimap/INSTALL.html#imapsend
+ */
+ if (option (OPTUSESENDBOX))
+ return mutt_write_fcc (NONULL (Sendbox), msg, NULL, 0, NULL, 1);
+
/* Write out the message in MIME form. */
mutt_mktemp (tempfile);
if ((tempfp = safe_fopen (tempfile, "w")) == NULL)
@@ -1489,7 +1495,7 @@ main_loop:
mutt_prepare_envelope (msg->env, 0);
mutt_env_to_idna (msg->env, NULL, NULL); /* Handle bad IDNAs the next
time. */
- if (!Postponed || mutt_write_fcc (NONULL (Postponed), msg, (cur &&
(flags & SENDREPLY)) ? cur->env->message_id : NULL, 1, fcc) < 0)
+ if (!Postponed || mutt_write_fcc (NONULL (Postponed), msg, (cur &&
(flags & SENDREPLY)) ? cur->env->message_id : NULL, 1, fcc, 0) < 0)
{
msg->content = mutt_remove_multipart (msg->content);
decode_descriptions (msg->content);
@@ -1669,7 +1675,7 @@ full_fcc:
* message was first postponed.
*/
msg->received = time (NULL);
- if (mutt_write_fcc (fcc, msg, NULL, 0, NULL) == -1)
+ if (mutt_write_fcc (fcc, msg, NULL, 0, NULL, 0) == -1)
{
/*
* Error writing FCC, we should abort sending.
diff -r b9caff41ea4e -r 68b578d136ac sendlib.c
--- a/sendlib.c Wed Aug 09 10:26:01 2006 -0400
+++ b/sendlib.c Wed Aug 09 10:30:33 2006 -0400
@@ -2277,7 +2277,7 @@ static void set_noconv_flags (BODY *b, s
}
}
-int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int
post, char *fcc)
+int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int
post, char *fcc, int send)
{
CONTEXT f;
MESSAGE *msg;
@@ -2309,7 +2309,7 @@ int mutt_write_fcc (const char *path, HE
}
}
- hdr->read = !post; /* make sure to put it in the `cur' directory (maildir) */
+ hdr->read = !(post || send); /* make sure to put it in the `cur' directory
(maildir) */
if ((msg = mx_open_new_message (&f, hdr, M_ADD_FROM)) == NULL)
{
mx_close_mailbox (&f, NULL);
@@ -2335,9 +2335,13 @@ int mutt_write_fcc (const char *path, HE
*/
if (post && fcc)
fprintf (msg->fp, "X-Mutt-Fcc: %s\n", fcc);
- fprintf (msg->fp, "Status: RO\n");
-
-
+
+ /* don't set RO flag if this is a send operation.
+ * FIXME: possibly could restrict to f.magic == M_MBOX too, I don't think any
+ * other formats use the Status header field
+ */
+ if (!send)
+ fprintf (msg->fp, "Status: RO\n");
/* (postponment) if the mail is to be signed or encrypted, save this info */
if ((WithCrypto & APPLICATION_PGP)