1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498
|
#
# This file contains various examples of configuration sections to use
# in your getmail rc file. You need one file for each mail account you
# want to retrieve mail from. These files should be placed in your
# getmail configuration/data directory
# (default: ~/.config/getmail/).
# If you only need one rc file, name it getmailrc in that directory,
# and you won't need to supply any commandline options to run getmail.
#
#
# Example 0: Using pass as password_command to manage your passwords,
# storing all messages in a maildir.
#
[retriever]
type = SimpleIMAPSSLRetriever
server = imap.gmail.com
port = 993
username = <your_email_here>
password_command = ("pass", "<your_email_here>")
[destination]
type = Maildir
path = ~/Mail/<your_email_here>/INBOX/
[options]
read_all = true
delete = true
#
# Example 1: simplest case of retrieving mail from one POP3 server and
# storing all messages in a maildir.
#
[retriever]
type = SimplePOP3Retriever
server = pop.example.net
username = jeff.plotzky
password = mailpassword
[destination]
type = Maildir
path = ~jeffp/Maildir/
#
# Example 2: same as (1), but operate quietly, delete messages from
# the server after retrieving them, and log getmail's actions (in detail)
# to a file.
#
[options]
verbose = 0
delete = true
message_log = ~/.getmail/log
message_log_verbose = true
[retriever]
type = SimplePOP3Retriever
server = pop.example.net
username = jeff.plotzky
password = mailpassword
[destination]
type = Maildir
path = ~jeffp/Maildir/
#
# Example 3: same as (1), but the mail account is accessed via IMAP4 instead
# of POP3.
#
[retriever]
type = SimpleIMAPRetriever
server = mail.example.net
username = jeff.plotzky
password = mailpassword
[destination]
type = Maildir
path = ~jeffp/Maildir/
#
# Example 4: same as (3), but retrieve mail from the INBOX, INBOX.spam, and
# mailing-lists.getmail-users mail folders.
#
[retriever]
type = SimpleIMAPRetriever
server = mail.example.net
username = jeff.plotzky
password = mailpassword
mailboxes = ("INBOX", "INBOX.spam", "mailing-lists.getmail-users")
[destination]
type = Maildir
path = ~jeffp/Maildir/
#
# Example 5: same as (3), but move messages to the mail folder "sent-mail"
# after retrieving them. Note that you do this by setting delete and
# move_on_delete options.
#
[options]
delete = true
[retriever]
type = SimpleIMAPRetriever
server = mail.example.net
username = jeff.plotzky
password = mailpassword
move_on_delete = sent-mail
[destination]
type = Maildir
path = ~jeffp/Maildir/
#
# Example 6: same as (1), but deliver the messages to an mboxrd-format mbox
# file as user "jeffp".
#
[retriever]
type = SimplePOP3Retriever
server = pop.example.net
username = jeff.plotzky
password = mailpassword
[destination]
type = Mboxrd
path = ~jeffp/Mail/inbox
user = jeffp
#
# Example 7: same as (1), but deliver the messages through an external MDA
# which takes several arguments.
#
[retriever]
type = SimplePOP3Retriever
server = pop.example.net
username = jeff.plotzky
password = mailpassword
[destination]
type = MDA_external
path = /usr/local/bin/my-mda
arguments = ("--message-from-stdin", "--scan-message", "--to-maildir",
"~jeffp/Maildir/")
#
# Example 8: retrieve mail from a corporate POP3-SSL domain mailbox,
# sort messages for several local users and deliver to maildirs in their
# home directories (except Sam, who likes mbox files, and Christina, who
# uses procmail for further sorting), and deliver all other mail to
# Joe, who serves as postmaster for the company. Sam also needs
# to receive mail for "sam1", "sam23", etc, so we use a regular expression
# matching "sam" plus zero or more decimal digits.
#
[retriever]
type = MultidropPOP3SSLRetriever
server = pop.example.net
username = companylogin
password = mailpassword
# Our domain mailbox mailhost records the envelope recipient address in a
# new Delivered-To: header field at the top of the message.
envelope_recipient = delivered-to:1
[destination]
type = MultiSorter
default = [postmaster]
locals = (
("jeffk@company.example.net", "[jeff]"),
("martinh@company.example.net", "[martin]"),
(r"sam\D*@company.example.net", "[sam]"),
("c.fellowes@company.example.net", "[christina-procmail]")
)
[postmaster]
type = Maildir
path = ~joe/Mail/postmaster/
user = joe
[jeff]
type = Maildir
path = ~jeffp/Maildir/
user = jeffp
[martin]
type = Maildir
path = ~martinh/Maildir/
user = martinh
[sam]
type = Mboxrd
path = ~sam/Mail/inbox
user = sam
[christina-procmail]
type = MDA_external
path = /usr/local/bin/procmail
# procmail requires either that the message starts with an mboxrd-style
# "From " line (which getmail can generate by setting "unixfrom" to True), or
# that the -f option is provided as below.
arguments = ("-f", "%(sender)", "-m", "/home/christina/.procmailrc")
user = christina
#
# Example 9: same as (3), but use SpamAssassin to filter out spam,
# and ClamAV to filter out MS worms.
#
[retriever]
type = SimpleIMAPRetriever
server = mail.example.net
username = jeff.plotzky
password = mailpassword
[filter-1]
type = Filter_external
path = /usr/local/bin/spamc
[filter-2]
type = Filter_classifier
path = /usr/local/bin/clamscan
arguments = ("--stdout", "--no-summary",
"--mbox", "--infected", "-")
exitcodes_drop = (1,)
[destination]
type = Maildir
path = ~jeffp/Maildir/
#
# Example 10: same as (3), but deliver all mail to two different local
# mailboxes.
#
[retriever]
type = SimpleIMAPRetriever
server = mail.example.net
username = jeff.plotzky
password = mailpassword
[destination]
type = MultiDestination
destinations = (
"~jeff/Maildir/",
"/var/log/mail-archive/current",
)
#
# Example 11: retrieve mail from a simple (non-multidrop) POP3 mailbox.
# Then extract addresses from the message header (see documentation for which
# fields are examined), and deliver mail containing the address
# <list1@domain.example.net> to ~/Mail/lists/list1/, mail containing the
# address <list2@otherdomain.example.com> to ~/Mail/lists/list2/,
# mail containing the address <othername@example.org> to ~/Mail/other/,
# and all other mail gets delivered through the external MDA program
# "my-mda" with some default arguments.
#
[retriever]
type = SimplePOP3Retriever
server = pop.example.net
username = jeff.plotzky
password = mailpassword
[destination]
type = MultiGuesser
default = [my-mda]
locals = (
("list1@domain.example.net", "~/Mail/lists/list1/"),
("list2@otherdomain.example.com", "~/Mail/lists/list2/"),
("othername@example.org", "~/Mail/other/"),
)
[my-mda]
type = MDA_external
path = /path/to/my-mda
arguments = ("-f", "%(sender)", "${HOME}/.mymdarc")
#
# Example 12: Gmail xoauth2 example
#
# A client_id and client_secret identify a web app or a desktop app.
# getmail-gmail-xoauth-tokens
# creates a local server with loopback redirect (127.0.0.1) to get the authorization.
# https://developers.google.com/identity/protocols/oauth2/native-app#redirect-uri_loopback
#
# To initialize do:
#
# Step1: Create a new OAuth 2.0 Client-ID
#
# - project create:
# https://console.cloud.google.com/projectcreate
# - consent screen:
# https://console.cloud.google.com/apis/credentials/consent
# only external available for non-workspace users.
# [ADD OR REMOVE SCOPE] https://mail.google.com/
# Test User: Add all your emails you want to use with getmail.
# - credential:
# https://console.cloud.google.com/apis/credentials
# [Create Credentials/Oauth client ID] Desktop App / getmail
# DOWNLOAD JSON
#
# Step 2: for each email you mentioned as test user above,
# create a file <email>.json according the below template.
#
# - Edit the email in each json file
# - copy two lines from the downloaded json into each json file
# client_id
# client_secret
#
# {"scope": "https://mail.google.com/",
# "user": "your-gmail-user@gmail.com",
# "client_id": "the new client id",
# "client_secret": "the new secret",
# "token_uri": "https://accounts.google.com/o/oauth2/token",
# "auth_uri": "https://accounts.google.com/o/oauth2/auth",
# "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs"}
#
# Step 3: init step, execute for each json file
#
# getmail-gmail-xoauth-tokens --init /path-to-your-users-getmail-directory/<email>.json
#
# It will ask you to visit a http url.
# On the browser:
# - There will be a warning "Google hasn't verified this app": continue.
# - Then there will be the consent screen: continue.
#
# getmail-gmail-xoauth-tokens will update the <email>.json file.
#
# Unfortunately this Step 3 needs to be repeated regularly.
# Therefore on should better opt for an google generated "app password".
#
# Step 4: Update the `[retriever]` section of the rc file as below.
# use_xoauth2 must be True, else [AUTHENTICATIONFAILED].
#
[retriever]
type = SimpleIMAPSSLRetriever
use_xoauth2 = True
server = imap.gmail.com
username = your-gmail-user@gmail.com
password_command = ("getmail-gmail-xoauth-tokens", "/path/to/your/users/getmail/directory/<email>.json")
#
# Example 13: Microsoft Office 365 IMAP4 xoauth2 example
#
# To initialize do:
#
# Step1: Create App Registration in Azure
#
# In a browser, open https://portal.azure.com
# Select "Microsoft Entra ID" (use the search if needed)
# Select "App Registrations"
# Select "New Registration"
# Enter a project name, eg "getmail".
# Select "Accounts in this organizational directory only (Single tenant)" from "Supported account types"
# Select type "Web" and enter "http://localhost" for "Redirect URI"
# Select "Register"
#
# Now, from the new App's details page, make a note of:
# * client_id
# * tenant_id
# (These are in the "Essentials" section.)
#
# Next create a secret by selecting "Certificates and secrets"
# Select "New client secret"
# * Description: password
# * Expires: select preferred expiry date
# Make a note of:
# * client_secret
# It is available by selecting "Value".
#
# Next add permissions:
#
# Select "API permissions", then "Add a permission".
# Select "Microsoft Graph"
# Select "Delegated permissions"
# Search and select the following permissions:
# * IMAP.AccessAsUser.All
# * offline_access
# Select "Add permissions"
# Step 2: Add the new credentials to the microsoft.json template
#
# {"scope": "https://outlook.office.com/IMAP.AccessAsUser.All offline_access",
# "user": "firstname.lastname@example.com",
# "client_id": "<client_id>",
# "client_secret": "<secret>",
# "token_uri": "https://login.microsoftonline.com/<tenant_id>/oauth2/v2.0/token",
# "auth_uri": "https://login.microsoftonline.com/<tenant_id>/oauth2/v2.0/authorize"}
#
# Step 3: execute:
#
# getmail-gmail-xoauth-tokens --init /path-to-your-users-getmail-directory/microsoft.json
#
# This will give you a URL you need to open in a browser.
# Opening this URL will generate a HTTP-redirect that connects back and updates the json file.
# Note: The script starts a local HTTP-server listening on http://localhost:8083.
# If you connect from a remote machine, you will need to forward that port to your local
# machine, so that the server can be reached via localhost:8083 on the machine running the browser.
# (You only need to do this once.)
#
# getmail-gmail-xoauth-tokens is waiting for the reconnect with the URL that contains the verification code.
# Once it received the callback
#
# getmail-gmail-xoauth-tokens will update the microsoft.json file. The json file
# will now contain the required tokens.
#
# Step 4: Update the `[retriever] `section of the rc file.
[retriever]
type = SimpleIMAPSSLRetriever
use_xoauth2 = True
server = outlook.office365.com
username = firstname.lastname@example.com
password_command = ("getmail-gmail-xoauth-tokens", "/path-to-your-users-getmail-directory/microsoft.json")
#
# Example 14: Personal Microsoft accounts (Outlook.com, Hotmail, Live, or MSN)
# IMAP4 xoauth2 example
#
# To initialize do:
#
# Step1: Create App Registration in Azure
# (You need a Microsoft Azure tenant)
#
# In a browser, open https://portal.azure.com
# Select "Microsoft Entra ID" (use the search if needed)
# Select "App Registrations"
# Select "New Registration"
# Enter a project name, eg "getmail".
# Select "Personal Microsoft accounts only" from "Supported account types"
# Select type "Web" and enter "http://localhost" for "Redirect URI"
# Select "Register"
#
# Now, from the new App's details page, make a note of:
# * client_id
# * tenant_id
# (These are in the "Essentials" section.)
#
# Next create a secret by selecting "Certificates and secrets"
# Select "New client secret"
# * Description: password
# * Expires: select preferred expiry date
# Make a note of:
# * client_secret
# It is available by selecting "Value".
#
# Next add permissions:
#
# Select "API permissions", then "Add a permission".
# Select "Microsoft Graph"
# Select "Delegated permissions"
# Search and select the following permissions:
# * IMAP.AccessAsUser.All
# * offline_access
# Select "Add permissions"
# Step 2: Add the new credentials to the microsoft.json template
#
# {"scope": "https://outlook.office.com/IMAP.AccessAsUser.All offline_access",
# "user": "firstname.lastname@example.com",
# "client_id": "<client_id>",
# "client_secret": "<secret>",
# "token_uri": "https://login.microsoftonline.com/consumers/oauth2/v2.0/token",
# "auth_uri": "https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize"}
#
# Step 3: execute:
#
# getmail-gmail-xoauth-tokens --init /path-to-your-users-getmail-directory/microsoft.json
#
# This will give you a URL you need to open in a browser.
# Opening this URL will generate a HTTP-redirect that connects back and updates the json file.
# Note: The script starts a local HTTP-server listening on http://localhost:8083.
# If you connect from a remote machine, you will need to forward that port to your local
# machine, so that the server can be reached via localhost:8083 on the machine running the browser.
# (You only need to do this once.)
#
# getmail-gmail-xoauth-tokens is waiting for the reconnect with the URL that contains the verification code.
# Once it received the callback
#
# getmail-gmail-xoauth-tokens will update the microsoft.json file. The json file
# will now contain the required tokens.
#
# Step 4: Update the `[retriever] `section of the rc file.
[retriever]
type = SimpleIMAPSSLRetriever
use_xoauth2 = True
server = outlook.office365.com
username = firstname.lastname@example.com
password_command = ("getmail-gmail-xoauth-tokens", "/path-to-your-users-getmail-directory/microsoft.json")
|