getting fetchmail/procmail to mark/split email by account or domain used to fetch

0

0

I've set up fetchmail to grab emails from two different accounts using POP, but I'd like them to be marked in such a way that Gnus or mutt can tell that they're from separate accounts for the purposes of reading and sorting. The same local user will be doing the reading.

What's the simplest way to do this?

bright-star

Posted 2013-12-24T10:31:23.573

Reputation: 1 489

Do you want separate msildir for each POP3 account? – AnFi – 2013-12-25T18:03:18.383

It would be nice to keep them separate. – bright-star – 2014-01-23T05:01:48.923

Answers

1

fetchmail & procmail : adding custom per fetched account header

You can

  1. make fetchmail deliver email directly via procmail script with custom per account parameter

  2. make procmail add custom header based on the parameter passed

  3. make gnus/mutt do splitting based on the custom header
    Splitting Mail - Gnus Manual

~/.fetchmailrc

# Pass messages fetched from account1 via procmail script .procmailrc
# executed with parameter ACCOUNT set to "account1"
poll account1
  ...
  mda procmail -m ACCOUNT=account1 .procmailrc

~/.procmailrc

# Add custom header based on ACCOUNT parameter
:0hw
* ACCOUNT ?? .
| formail -i "X-ACCOUNT: $ACCOUNT"

~/.gnus

;; https://www.gnu.org/software/emacs/manual/html_node/gnus/Splitting-Mail.html
 (setq nnmail-split-methods
   '(("mail.account1" "^X-ACCOUNT: account1")
     ("mail.other" "")))

AnFi

Posted 2013-12-24T10:31:23.573

Reputation: 771

1

For Gnus:

If the two different accounts have different email addresses then you can split based upon the To: header. This may not work if there are mailing lists that those addresses are subscribed to. But that could be fixed up with a few more splitting rules.

This is how I do my splitting from my 5 mail addresses (3 primary ones and 2 minor ones).

If that is not sufficient then perhaps splitting on Delivered-To:.

Refer to the Splitting Mail section of the Gnus manual.

verdammelt

Posted 2013-12-24T10:31:23.573

Reputation: 369

Sorry, do you have a link or a config snippet? – bright-star – 2014-01-23T05:02:13.083

Take a look at Splitting Mail in Emacs Manual - it provides examples of splitting (redirecting to folders/groups) based on message headers. BTW Do not forget about CC: and lost Bcc: - splitting based on custom "per account" header inserted by fetchmail&procmail is safer IMHO.

– AnFi – 2014-01-23T12:20:44.153

duh, a link would have been good - thanks @AndrzejA.Filip – verdammelt – 2014-01-23T12:35:58.913