[PATCH] Extraneous SMTP messages in batch mode
In the thread, "Segmentation fault from mutt-1.5.17 with SMTP," I
wrote that when using mutt's built-in SMTP client to send messages
in batch mode, mutt printed the following messages:
Looking up mailsvr.spk.agilent.com...
Connecting to mailsvr.spk.agilent.com...
Sending message... 0K/0.4K (0%)
Sending message... 0K/0.4K (0%)
Sending message... 0K/0.4K (0%)
Sending message... 0K/0.4K (0%)
Sending message... 0K/0.4K (0%)
Sending message... 0K/0.4K (0%)
Sending message... 0K/0.4K (0%)
Sending message... 0K/0.4K (0%)
Sending message... 0K/0.4K (0%)
Sending message... 0K/0.4K (0%)
Sending message... 0K/0.4K (0%)
Sending message... 0K/0.4K (0%)
Sending message... 0K/0.4K (0%)
Sending message... 0K/0.4K (0%)
Messages like those are normally printed only in interactive mode.
I think it was just an oversight that they are printed in batch mode
as well. The attached patch fixes that behavior.
The changes were made to source files from the HEAD branch of the
mercurial repository at http://dev.mutt.org/hg/mutt, updated last
night.
Regards,
Gary
--- mutt_socket.c.orig 2008-11-11 20:51:26.836140000 -0800
+++ mutt_socket.c 2008-11-15 13:55:08.123247000 -0800
@@ -474,7 +474,8 @@
host_idna = conn->account.host;
# endif
- mutt_message (_("Looking up %s..."), conn->account.host);
+ if (!option(OPTNOCURSES))
+ mutt_message (_("Looking up %s..."), conn->account.host);
rc = getaddrinfo (host_idna, port, &hints, &res);
@@ -490,7 +491,8 @@
return -1;
}
- mutt_message (_("Connecting to %s..."), conn->account.host);
+ if (!option(OPTNOCURSES))
+ mutt_message (_("Connecting to %s..."), conn->account.host);
rc = -1;
for (cur = res; cur != NULL; cur = cur->ai_next)
@@ -532,7 +534,8 @@
host_idna = conn->account.host;
# endif
- mutt_message (_("Looking up %s..."), conn->account.host);
+ if (!option(OPTNOCURSES))
+ mutt_message (_("Looking up %s..."), conn->account.host);
he = gethostbyname (host_idna);
@@ -546,7 +549,8 @@
return -1;
}
- mutt_message (_("Connecting to %s..."), conn->account.host);
+ if (!option(OPTNOCURSES))
+ mutt_message (_("Connecting to %s..."), conn->account.host);
rc = -1;
for (i = 0; he->h_addr_list[i] != NULL; i++)
--- smtp.c.orig 2008-11-11 20:51:28.560412000 -0800
+++ smtp.c 2008-11-15 14:01:48.974838000 -0800
@@ -155,8 +155,9 @@
}
stat (msgfile, &st);
unlink (msgfile);
- mutt_progress_init (&progress, _("Sending message..."), M_PROGRESS_SIZE,
- NetInc, st.st_size);
+ if (!option(OPTNOCURSES))
+ mutt_progress_init (&progress, _("Sending message..."), M_PROGRESS_SIZE,
+ NetInc, st.st_size);
snprintf (buf, sizeof (buf), "DATA\r\n");
if (mutt_socket_write (conn, buf) == -1)
@@ -190,7 +191,8 @@
return smtp_err_write;
}
- mutt_progress_update (&progress, ftell (fp), -1);
+ if (!option(OPTNOCURSES))
+ mutt_progress_update (&progress, ftell (fp), -1);
}
fclose (fp);