Some Linux Tips




LINKS

Some Debian Tips
awardspace.com "free webhost"
drivehq.com "free storage"
spideroak.com "free storage"
dnsexit dynamic dns server
freedns.afraid dynamic dns server
dns.he.net dynamic dns server




index   Previous   Next


There are some mail retriever agents like getmail, mpop, mailfilter and fetchmail to retrieve the emails from the remoter mail servers to local mail server with POP3, IMAP4, ETRN ... protocols. .
Here we use the getmail4 which is simple, secure, and reliable. Install the getmail4 with aptitude.
Create dir for getmail configuration in the home:

mkdir ~/.getmail

Create a configuraion file for getmailrc in the .getmail dir:

touch ~/.getmail/getmailrc

To read the getmail configuration in detaills read the http://pyropus.ca/software/getmail/configuration.html
For each account should make one getmailrc file and will have the all parameters written like getmailrc, getmailrc0, getmailrc1 and then make a script like getmail.sh to retrieve the mails from all these accounts:

#!/bin/sh
GETMAIL="/usr/bin/getmail"
RCFILE="--rcfile getmailrc0 --rcfile getmailrc1 --rcfile getmailrc2 --rcfile getmailrc3"
set -e
cd /home/user/.getmail
$GETMAIL $RCFILE


This is for simple pop mail retrieval and destination to deliver the mails is the user mbox:

verbose = 1
read_all = false
delete = true
message_log = ~/.getmail/log
message_log_verbose = true

[retriever]
type = SimplePOP3Retriever
server = pop.someprovider.tld
username = falko@someprovider.tld
password = secret

[destination]
type = Mboxrd
path = /var/mail/falko


Each server will have the above tree sections the options, retriever and the destinaion where the mail will go, we will describe the each section alone for ease.
In the options verbose=1 will print the progress in the terminal and delete=true will delete the messages from the server and message_log will log the actions.
Some mail servers use SSL or TLS like gmail this is how retrieve with SSL:

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


This to retrieve with IMAP and tell which dirs we reterieve and move on deletion to wich folder:

[retriever]
type = SimpleIMAPRetriever
server = mail.example.net
username = jeff.plotzky
password = mailpassword
mailboxes = ("INBOX", "INBOX.spam", "mailing-lists.getmail-users")
move_on_delete = sent-mail


If you want to deliver the mails for destination to external MTA like exim4:

[destination]
type = MDA_external
path = /usr/sbin/exim4
arguments = ("-i", "-bm", "users@localhost")
unixfrom = true


As you see, we tell getmail that users local email address is users@localhost.
You can use the eache user home mail dirs for destination like qmail delivery:

[destination]
type = Maildir
path = ~/Maildir/
OR
path = /home/users/Maildir/~/Maildir/


Create three dirs in the Maildir:

mkdir -p ~/Maildir/cur/
mkdir -p ~/Maildir/new/
mkdir -p ~/Maildir/tmp/


For more retrieval and delivery options read the sample getmailrc