Add proxy config to Getmail with oauth2#

Add proxy env to getmail-gmail-xoauth-tokens

Getmail config#

[retriever]
type = SimpleIMAPSSLRetriever
server = imap.gmail.com
port = 993
username = example@example.com
use_xoauth2 = True
# password_command require two parameters
password_command = ("get_google_token_with_proxy.sh", " ")

[destination]
type = Maildir
path = ~/.maildir/

[options]
delete = true
# print messages about each action (verbose = 2)
# Other options:
# 0 prints only warnings and errors
# 1 prints messages about retrieving and deleting messages only
verbose = 2
message_log = ~/getmail.log

Bash script with proxy config#

#!/bin/bash -e

HTTP_PROXY='http://user:pass@proxy.example.com:3128' HTTPS_PROXY='http://user:pass@proxy.example.com:3128' getmail-gmail-xoauth-tokens token.json