Difference between revisions of "Getmail"

From ArchWiki
Jump to: navigation, search
(some initial work on the configuration)
m (add ja link)
 
(14 intermediate revisions by 8 users not shown)
Line 1: Line 1:
 
[[Category:Mail Server]]
 
 
{{DISPLAYTITLE:getmail}}
 
{{DISPLAYTITLE:getmail}}
 +
[[Category:Mail server]]
 +
[[ja:Getmail]]
 +
{{Poor writing|cron ({{Pkg|cronie}}) is not included in {{Grp|base}} anymore and has to be installed manually, or use [[systemd/Timers]] instead}}
  
{{Stub|Work in progress.}}
+
[[Wikipedia:getmail|getmail]] is a mail retriever designed to allow you to get your mail from one or more mail accounts on various mail servers to your local machine for reading with a minimum of fuss. ''getmail'' is designed to be secure, flexible, reliable, and easy-to-use. ''getmail'' is designed to replace other mail retrievers such as [[Wikipedia:Fetchmail|fetchmail]].
 
+
[[Wikipedia:getmail|getmail]] is a mail retriever designed to allow you to get your mail from one or more mail accounts on various mail servers to your local machine for reading with a minimum of fuss. '''getmail''' is designed to be secure, flexible, reliable, and easy-to-use. '''getmail''' is designed to replace other mail retrievers such as [[Wikipedia:Fetchmail|fetchmail]].  For more detailed information, please see the official [http://pyropus.ca/software/getmail/ getmail documentation].
+
  
 
==Installation==
 
==Installation==
  
[[pacman|Install]] the package {{Pkg|getmail}} from the [[Official Repositories|official repositories]].
+
[[Install]] the package {{Pkg|getmail}} from the [[official repositories]].
  
 
==Configuration==
 
==Configuration==
  
* Create a configuration dir and set the right permissions by executing: {{ic|$ mkdir -m 0700 $HOME/.getmail}}.
+
* Create a configuration directory, and set the right permissions by executing: {{ic|$ mkdir -m 0700 ~/.getmail}}. The main configuration file often contains sensitive information, namely passwords in plain text.
* Create a configuration file, the default being: {{ic|~/getmail/getmailrc}}. A separate configuration file is needed for each mailserver to pick up mail from. Configuration files other than the default, will have to be explicitly passed as arguments to the getmail command.
+
* Create a configuration file, the default being: {{ic|~/.getmail/getmailrc}}. A separate configuration file is needed for each mailserver to pick up mail from. Configuration files other than the default, will have to be explicitly passed as arguments to the getmail command.
 +
 
 +
===Retrieving mail===
 +
 
 +
Here is an example {{ic|getmailrc}} used with a gmail account.
 +
{{bc|1=
 +
[retriever]
 +
type = SimplePOP3SSLRetriever
 +
server = pop.gmail.com
 +
username = username@gmail.com
 +
port = 995
 +
password = password
 +
 
 +
[destination]
 +
type = Maildir
 +
path = ~/mail/
 +
}}
 +
 
 +
You can tweak this to your POP3 service's specification.
 +
 
 +
To store the password in a keyring instead of in plain text in the configuration file, setup [[GNOME Keyring]], and install the {{Pkg|python2-gnomekeyring}} package. Then, delete the {{ic|password}} entry from {{ic|getmailrc}}, and run
 +
 
 +
  getmail --store-password-in-gnome-keyring
 +
 
 +
type the password when prompted to have it saved into the keyring.
 +
 
 +
Most people will like to add the following section to their {{ic|getmailrc}} to prevent all the mail on the server being downloaded every time getmail is ran.
 +
{{bc|1=
 +
[options]
 +
read_all = False
 +
}}
 +
 
 +
For this guide we will be storing our mail in the {{ic|maildir}} format. The two main mailbox formats are {{ic|mbox}} and {{ic|maildir}}. The main difference between the two is that {{ic|mbox}} is one file, with all of your mails and their headers stored in it, whereas a {{ic|maildir}} is a directory tree. Each mail is its own file, which will often speed things up.
 +
 
 +
A {{ic|maildir}} is just a folder with the folders {{ic|cur}}, {{ic|new}} and {{ic|tmp}} in it.
 +
$ mkdir -p ~/mail/{cur,new,tmp}
 +
 
 +
Now, run getmail. If it works fine, you can create a cronjob for getmail to run every n hours/minutes. Type {{ic|crontab -e}} to edit cronjobs, and enter the following:
 +
  */10 * * * * /usr/bin/getmail
 +
That will run {{ic|getmail}} every 10 minutes.
 +
 
 +
Also, to quiet getmail down, we can reduce its verbosity to zero by adding the following to {{ic|getmailrc}}.
 +
{{bc|1=
 +
[options]
 +
verbose = 0
 +
}}
 +
 
 +
====More than one Email account with getmail====
 +
By default, when you run {{ic|getmail}} the program searches for the file getmailrc created as seen above. If you have more than one mail account you would like to get mail from, then you can create such a file for each email address, and then tell getmail to run using both of them.  Obviously if you have two accounts and two files you cannot have both of them called getmailrc. What you do is give them two different names, using myself as an example: I call one personal, and one university. These two files contain content relevant to my personal mail, and my university work mail respectively. Then to get getmail to work on these two files, instead of searching for getmailrc(default), I use the --rcfile switch like so: {{ic|getmail --rcfile university --rcfile personal}} This can work with more files if you have more email accounts, just make sure each file is in the .getmail directory and make sure to  alter the cronjob to run the command with the --rcfile switches. E.g.
 +
  */30 * * * * /usr/bin/getmail --rcfile university --rcfile personal
 +
 
 +
Obviously you can call your files whatever you want, providing you include them in the cronjob or shell command, and they are in the .getmail/ directory, getmail will fetch mail from those two accounts.
 +
 
 +
===Sorting mail with procmail===
 +
Edit your getmailrc to pass retrieved mail to procmail:
 +
{{bc|1=
 +
[destination]
 +
type = MDA_external
 +
path = /usr/bin/procmail
 +
}}
 +
 
 +
Then configure [[procmail]] to filter your mail.
 +
 
 +
== See also ==
 +
 
 +
* [http://pyropus.ca/software/getmail/ getmail documentation]
 +
* [http://pyropus.ca/software/getmail/configuration.html#running Documentation on Configuring Getmail with rcfiles]
 +
* How to [[Backup Gmail with getmail]].

Latest revision as of 07:40, 16 October 2016

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements.Tango-edit-clear.png

Reason: cron (cronie) is not included in base anymore and has to be installed manually, or use systemd/Timers instead (Discuss in Talk:Getmail#)
getmail is a mail retriever designed to allow you to get your mail from one or more mail accounts on various mail servers to your local machine for reading with a minimum of fuss. getmail is designed to be secure, flexible, reliable, and easy-to-use. getmail is designed to replace other mail retrievers such as fetchmail.

Installation

Install the package getmail from the official repositories.

Configuration

  • Create a configuration directory, and set the right permissions by executing: $ mkdir -m 0700 ~/.getmail. The main configuration file often contains sensitive information, namely passwords in plain text.
  • Create a configuration file, the default being: ~/.getmail/getmailrc. A separate configuration file is needed for each mailserver to pick up mail from. Configuration files other than the default, will have to be explicitly passed as arguments to the getmail command.

Retrieving mail

Here is an example getmailrc used with a gmail account.

[retriever]
type = SimplePOP3SSLRetriever
server = pop.gmail.com
username = username@gmail.com
port = 995
password = password

[destination]
type = Maildir
path = ~/mail/

You can tweak this to your POP3 service's specification.

To store the password in a keyring instead of in plain text in the configuration file, setup GNOME Keyring, and install the python2-gnomekeyring package. Then, delete the password entry from getmailrc, and run

 getmail --store-password-in-gnome-keyring

type the password when prompted to have it saved into the keyring.

Most people will like to add the following section to their getmailrc to prevent all the mail on the server being downloaded every time getmail is ran.

[options]
read_all = False

For this guide we will be storing our mail in the maildir format. The two main mailbox formats are mbox and maildir. The main difference between the two is that mbox is one file, with all of your mails and their headers stored in it, whereas a maildir is a directory tree. Each mail is its own file, which will often speed things up.

A maildir is just a folder with the folders cur, new and tmp in it.

$ mkdir -p ~/mail/{cur,new,tmp}

Now, run getmail. If it works fine, you can create a cronjob for getmail to run every n hours/minutes. Type crontab -e to edit cronjobs, and enter the following:

 */10 * * * * /usr/bin/getmail

That will run getmail every 10 minutes.

Also, to quiet getmail down, we can reduce its verbosity to zero by adding the following to getmailrc.

[options]
verbose = 0

More than one Email account with getmail

By default, when you run getmail the program searches for the file getmailrc created as seen above. If you have more than one mail account you would like to get mail from, then you can create such a file for each email address, and then tell getmail to run using both of them. Obviously if you have two accounts and two files you cannot have both of them called getmailrc. What you do is give them two different names, using myself as an example: I call one personal, and one university. These two files contain content relevant to my personal mail, and my university work mail respectively. Then to get getmail to work on these two files, instead of searching for getmailrc(default), I use the --rcfile switch like so: getmail --rcfile university --rcfile personal This can work with more files if you have more email accounts, just make sure each file is in the .getmail directory and make sure to alter the cronjob to run the command with the --rcfile switches. E.g.

 */30 * * * * /usr/bin/getmail --rcfile university --rcfile personal

Obviously you can call your files whatever you want, providing you include them in the cronjob or shell command, and they are in the .getmail/ directory, getmail will fetch mail from those two accounts.

Sorting mail with procmail

Edit your getmailrc to pass retrieved mail to procmail:

[destination]
type = MDA_external
path = /usr/bin/procmail

Then configure procmail to filter your mail.

See also