for), and what lists you are subscribed to. This is accomplished
through the use of the <link linkend="lists"><command>lists</command>
and <command>subscribe</command></link> commands in your
-<literal>.muttrc</literal>.
+<literal>.muttrc</literal>. Alternatively or additionally, you can set
+<link linkend="auto-subscribe">$auto_subscribe</link> to automatically
+subscribe addresses found in a <literal>List-Post</literal> header.
</para>
<para>
WHERE HASH *Groups;
WHERE HASH *ReverseAlias;
+WHERE HASH *AutoSubscribeCache;
WHERE LIST *AutoViewList INITVAL(0);
WHERE LIST *AlternativeOrderList INITVAL(0);
restore_address(&e->mail_followup_to, d, off, convert);
restore_char(&e->list_post, d, off, convert);
+ if (option (OPTAUTOSUBSCRIBE))
+ mutt_auto_subscribe (e->list_post);
+
restore_char(&e->subject, d, off, convert);
restore_int((unsigned int *) (&real_subj_off), d, off);
static int parse_unlists (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
{
+ hash_destroy (&AutoSubscribeCache, NULL);
do
{
mutt_extract_token (buf, s, 0);
static int parse_unsubscribe (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
{
+ hash_destroy (&AutoSubscribeCache, NULL);
do
{
mutt_extract_token (buf, s, 0);
** will use your locale environment, so there is no need to set
** this except to override that default.
*/
+ { "auto_subscribe", DT_BOOL, R_NONE, OPTAUTOSUBSCRIBE, 0 },
+ /*
+ ** .pp
+ ** When \fIset\fP, Mutt assumes the presence of a List-Post header
+ ** means the recipient is subscribed to the list. Unless the mailing list
+ ** is in the ``unsubscribe'' or ``unlist'' lists, it will be added
+ ** to the ``$subscribe'' list. Parsing and checking these things slows
+ ** header reading down, so this option is disabled by default.
+ */
{ "auto_tag", DT_BOOL, R_NONE, OPTAUTOTAG, 0 },
/*
** .pp
OPTASKCC,
OPTATTACHSPLIT,
OPTAUTOEDIT,
+ OPTAUTOSUBSCRIBE,
OPTAUTOTAG,
OPTBEEP,
OPTBEEPNEW,
cur->attach_valid = 0;
}
+void mutt_auto_subscribe (const char *mailto)
+{
+ ENVELOPE *lpenv;
+
+ if (!AutoSubscribeCache)
+ AutoSubscribeCache = hash_create (200, MUTT_HASH_STRCASECMP | MUTT_HASH_STRDUP_KEYS);
+
+ if (!mailto || hash_find (AutoSubscribeCache, mailto))
+ return;
+
+ hash_insert (AutoSubscribeCache, mailto, AutoSubscribeCache);
+
+ lpenv = mutt_new_envelope (); /* parsed envelope from the List-Post mailto: URL */
+
+ if ((url_parse_mailto (lpenv, NULL, mailto) != -1) &&
+ lpenv->to && lpenv->to->mailbox &&
+ !mutt_match_rx_list (lpenv->to->mailbox, SubscribedLists) &&
+ !mutt_match_rx_list (lpenv->to->mailbox, UnMailLists) &&
+ !mutt_match_rx_list (lpenv->to->mailbox, UnSubscribedLists))
+ {
+ BUFFER err;
+ char errbuf[STRING];
+
+ memset (&err, 0, sizeof(err));
+ err.data = errbuf;
+ err.dsize = sizeof(errbuf);
+
+ /* mutt_add_to_rx_list() detects duplicates, so it is safe to
+ * try to add here without any checks. */
+ mutt_add_to_rx_list (&MailLists, lpenv->to->mailbox, REG_ICASE, &err);
+ mutt_add_to_rx_list (&SubscribedLists, lpenv->to->mailbox, REG_ICASE, &err);
+ }
+ mutt_free_envelope (&lpenv);
+}
+
int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p, short user_hdrs, short weed,
short do_2047, LIST **lastp)
{
{
FREE (&e->list_post);
e->list_post = mutt_substrdup (beg, end);
+ if (option (OPTAUTOSUBSCRIBE))
+ mutt_auto_subscribe (e->list_post);
break;
}
}
void mutt_adv_mktemp (char *, size_t);
void mutt_alias_menu (char *, size_t, ALIAS *);
void mutt_allow_interrupt (int);
+void mutt_auto_subscribe (const char *);
void mutt_block_signals (void);
void mutt_block_signals_system (void);
int mutt_body_handler (BODY *, STATE *);