Hi, This is an interesting FEATURE request/proposal with patch.
I think this should be accepted by the upstream first. Hi upstream, This is a forwarded bug report from Debian. I got kicked out of mailimg list sometime ago. I hope this reaches you. (I just resubscribed) ----- Forwarded message from Daniel Kahn Gillmor <d...@debian.org> ----- Date: Thu, 23 Feb 2017 14:07:09 -0500 From: Daniel Kahn Gillmor <d...@debian.org> To: Josh Triplett <j...@joshtriplett.org>, 833...@bugs.debian.org Subject: Bug#833190: Please provide an option to not add X-getmail-retrieved-from-mailbox header Control: tags 833190 + patch On Mon 2016-08-01 19:25:38 -0400, Josh Triplett wrote: > When getmail retrieves a mail, it unconditionally adds a header > X-getmail-retrieved-from-mailbox with the name of the mailbox it retrieved the > mail from. As far as I can tell, getmail doesn't have any option to avoid > adding that header. I'd like to leave the mail completely unmodified. Would > you consider adding an option to not add that header? I went to report this issue on the BTS, but saw that Josh has beaten me to it, as usual. :) Attached is a patch that seems to work for me. To use it, i added: record_retrieved_from_mailbox = False to the [Retriever] section of ~/.getmail/config/mymailprovider Feel free to forward it upstream :) hth, --dkg From: Daniel Kahn Gillmor <d...@fifthhorseman.net> Date: Thu, 23 Feb 2017 13:56:54 -0500 Subject: Make X-getmail-retrieved-from-mailbox optional (Closes: #833190) In https://bugs.debian/833190, Josh Triplett asked for getmail to avoid modifying messages as they are fetched via IMAP. This should provide such an option. --- docs/configuration.html | 7 +++++++ docs/configuration.txt | 5 +++++ getmailcore/_retrieverbases.py | 7 ++++--- getmailcore/retrievers.py | 4 ++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/docs/configuration.html b/docs/configuration.html index 0508ddf..c79610a 100644 --- a/docs/configuration.html +++ b/docs/configuration.html @@ -635,6 +635,13 @@ mailboxes = ALL <a href="http://honk.sigxcpu.org/projects/pykerberos/">http://honk.sigxcpu.org/projects/pykerberos/"</a> for details. </li> + <li> + record_retrieved_from_mailbox + (<a href="#parameter-boolean">boolean</a>) + — whether to add a <tt>X-getmail-retrieved-from-mailbox</tt> header + to each message fetched; the default is True. Note that setting this to False + will break the use of %(mailbox) as a substitution in MDA_external arguments. + </li> </ul> <h4 id="retriever-ssl-client">SSL Client Parameters</h4> diff --git a/docs/configuration.txt b/docs/configuration.txt index a3cbe0d..ed4fdc0 100644 --- a/docs/configuration.txt +++ b/docs/configuration.txt @@ -401,6 +401,11 @@ mailboxes = ALL pykerberos with GSS support is installed; check your OS distribution or see http://honk.sigxcpu.org/projects/pykerberos/" for details. + * record_retrieved_from_mailbox (boolean) -- whether to add a + X-getmail-retrieved-from-mailbox header to each message + fetched; the default is True. Note that setting this to False + will break the use of %(mailbox) as a substitution in + MDA_external arguments. SSL Client Parameters diff --git a/getmailcore/_retrieverbases.py b/getmailcore/_retrieverbases.py index e4592e0..31e7170 100755 --- a/getmailcore/_retrieverbases.py +++ b/getmailcore/_retrieverbases.py @@ -1556,9 +1556,10 @@ class IMAPRetrieverBase(RetrieverSkeleton): raise getmailRetrievalError('failed to retrieve msgid %s' % msgid) - # record mailbox retrieved from in a header - msg.add_header('X-getmail-retrieved-from-mailbox', - self.mailbox_selected) + if self.conf['record_retrieved_from_mailbox']: + # record mailbox retrieved from in a header + msg.add_header('X-getmail-retrieved-from-mailbox', + self.mailbox_selected) # google extensions: apply labels, etc if 'X-GM-EXT-1' in self.conn.capabilities: diff --git a/getmailcore/retrievers.py b/getmailcore/retrievers.py index 6e82df7..a2b36bb 100755 --- a/getmailcore/retrievers.py +++ b/getmailcore/retrievers.py @@ -376,6 +376,7 @@ class SimpleIMAPRetriever(IMAPRetrieverBase, IMAPinitMixIn): # .authenticate(), so we can't do this yet (?). ConfBool(name='use_cram_md5', required=False, default=False), ConfBool(name='use_kerberos', required=False, default=False), + ConfBool(name='record_retrieved_from_mailbox', required=False, default=True), ) received_from = None received_with = 'IMAP4' @@ -423,6 +424,7 @@ class SimpleIMAPSSLRetriever(IMAPRetrieverBase, IMAPSSLinitMixIn): # .authenticate(), so we can't do this yet (?). ConfBool(name='use_cram_md5', required=False, default=False), ConfBool(name='use_kerberos', required=False, default=False), + ConfBool(name='record_retrieved_from_mailbox', required=False, default=True), ) received_from = None received_with = 'IMAP4-SSL' @@ -463,6 +465,7 @@ class MultidropIMAPRetriever(MultidropIMAPRetrieverBase, IMAPinitMixIn): ConfBool(name='use_cram_md5', required=False, default=False), ConfBool(name='use_kerberos', required=False, default=False), ConfString(name='envelope_recipient'), + ConfBool(name='record_retrieved_from_mailbox', required=False, default=True), ) received_from = None received_with = 'IMAP4' @@ -511,6 +514,7 @@ class MultidropIMAPSSLRetriever(MultidropIMAPRetrieverBase, IMAPSSLinitMixIn): ConfBool(name='use_cram_md5', required=False, default=False), ConfBool(name='use_kerberos', required=False, default=False), ConfString(name='envelope_recipient'), + ConfBool(name='record_retrieved_from_mailbox', required=False, default=True), ) received_from = None received_with = 'IMAP4-SSL' ----- End forwarded message -----