There are mail retriever like getmail4, mpop, mailfilter and fetchmail to
retrieve emails from the remote mail servers to local mail box with POP3, IMAP4, ETRN ... protocols.
.
we configure getmail4, which is simple, secure, and reliable. Install the getmail with:
apt install getmail4
Create configuration directory for getmail in home:
mkdir ~/.getmail
For more detaills read
http://pyropus.ca/software/getmail/configuration.html
touch ~/.getmail/getmailrc
And a bash script to read all these getmailrc files:
#!/bin/sh
GETMAIL="/usr/bin/getmail"
RCFILE="--rcfile getmailrc0 --rcfile getmailrc1 --rcfile getmailrc2 --rcfile getmailrc3"
set -e
cd ~/.getmail
$GETMAIL $RCFILE
This is for simple pop mail retrieval and to deliver the mails in the user mbox:
[options]
verbose = 1
read_all = false
delete = true
received = false
delivered_to = false
message_log = ~/.getmail/log
message_log_verbose = true
[retriever]
type = SimplePOP3Retriever
server = pop.someprovider.tld
username = [email protected]
password = secret
[destination]
type = Mboxrd
path = /var/mail/falko
The option verbose=1 will print the progress in the terminal and "delete=true" will delete the
messages from the server or "delete_after = 10" to delete only mails older than ten days,
"read_all= false" to retrieve only new message, "received = false" and "delivered_to = false"
prevent getmail from adding additional headers to your mail and
and "message_log" will log the actions.
[retriever]
type = SimplePOP3SSLRetriever
server = pop.gmail.com
port = 995
username = [email protected]
password = secret
This to retrieve with IMAP protocol and tell which dirs to 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
To deliver the mails to an external MTA like exim4:
[destination]
type = MDA_external
path = /usr/sbin/exim4
arguments = ("-i", "-bm", "user@localhost")
unixfrom = true
As you see, we tell getmail that users local email address is user@localhost.
[destination]
type = Maildir
path = ~/Maildir/
OR
path = /home/user/Maildir/
Create three dirs in the Maildir:
mkdir -p ~/Maildir/cur/
mkdir -p ~/Maildir/new/
mkdir -p ~/Maildir/tmp/
[retriever]
type = MultidropIMAPSSLRetriever
envelope_recipient = delivered-to:1
server = localhost
port = 993
username = yourusername
password = yourpassword
mailboxes = ("INBOX",)
move_on_delete = .Trash
[destination]
type = MDA_external
path = /usr/local/libexec/dovecot/deliver
arguments = ("-e", "-f", "%(sender)", "-d", "%(recipient)")
user = mailaccess
group = mailaccess
[options]
read_all = false
delete = true
received = false
delivered_to = false
message_log = ~/.getmail/mvmail.log