The name or address of your POP3 server.
+<sect2>pop_last<label id="pop_last">
+<p>
+Type: boolean<newline>
+Default: unset
+
+If this variable is set, mutt will try to use the "LAST" POP command
+for retrieving only unread messages from the POP server.
+
<sect2>pop_pass<label id="pop_pass">
<p>
Type: string<newline>
#ifdef USE_POP
{ "pop_delete", DT_BOOL, R_NONE, OPTPOPDELETE, 0 },
{ "pop_host", DT_STR, R_NONE, UL &PopHost, UL "" },
+ { "pop_last", DT_BOOL, R_NONE, OPTPOPLAST, 0 },
{ "pop_port", DT_NUM, R_NONE, UL &PopPort, 110 },
{ "pop_pass", DT_STR, R_NONE, UL &PopPass, UL "" },
{ "pop_user", DT_STR, R_NONE, UL &PopUser, UL "" },
struct hostent *he;
char buffer[2048];
char msgbuf[SHORT_STRING];
- int s, i, msgs, bytes, err = 0;
+ int s, i, last = 0, msgs, bytes, err = 0;
CONTEXT ctx;
MESSAGE *msg = NULL;
if (mx_open_mailbox (NONULL(Spoolfile), M_APPEND, &ctx) == NULL)
goto finish;
+ /* only get unread messages */
+ if(option(OPTPOPLAST))
+ {
+ write (s, "last\r\n", 6);
+ if (getLine (s, buffer, sizeof (buffer)) == -1)
+ goto fail;
+
+ if (strncmp (buffer, "+OK", 3) == 0)
+ sscanf (buffer, "+OK %d", &last);
+ else
+ /* ignore an error here and assume all messages are new */
+ last = 0;
+ }
+
snprintf (msgbuf, sizeof (msgbuf),
msgs > 1 ? _("Reading %d new message (%d bytes)...") :
- ("Reading %d new messages (%d bytes)..."), msgs, bytes);
+ ("Reading %d new messages (%d bytes)..."), msgs - last, bytes);
mutt_message (msgbuf);
- for (i = 1 ; i <= msgs ; i++)
+ for (i = last + 1 ; i <= msgs ; i++)
{
snprintf (buffer, sizeof(buffer), "retr %d\r\n", i);
write (s, buffer, strlen (buffer));