How to install & configure getmail, replacement of Fetchmail utitity ?

How to install & configure getmail, replacement of Fetchmail utitity ?


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.
getmail version 4 includes the following features:
  • simple to install, configure, and use
  • retrieve virtually any mail
    • support for accessing mailboxes with the following protocols:
      • POP3
      • POP3-over-SSL
      • IMAP4
      • IMAP4-over-SSL
      • SDPS (Demon UK's extensions to POP3)
    • support for single-user and domain mailboxes
    • retrieve mail from an unlimited number of mailboxes and servers
    • can remember which mail it has already retrieved, and can be set to only download new messages
  • support for message filtering, classification, and annotation by external programs like spam filters and anti-virus programs
  • support for delivering messages to different destinations based on the message recipient
  • reliability
    • native safe and reliable delivery support for maildirs and mboxrd files, in addition to delivery through arbitrary external message delivery agents (MDAs)
    • does not destroy information by rewriting mail headers
    • does not cause mail loops by doing SMTP injection, and therefore does not require that you run an MTA (like qmail or sendmail) on your host
  • written in Python, and therefore easy to extend or customize
    • a flexible, extensible architecture so that support for new mail access protocols, message filtering operations, or destination types can be easily added
    • cross-platform operation; getmail 4 should work on Unix/Linux, Macintosh, and other platforms. Windows support available under the free Cygwin package.

Requirements:

Python should be installed on the server using getmail.


How to install getmail :

You have two ways to do it, either you configure 3rd party repos and install in by,

             #yum install getmail*

Or simply download getmail-3.2.5-1.noarch.rpm and install it through,

            #rpm -ivh getmail-3.2.5-1.noarch.rpm


How to Configure it:

Login to your Mail server,

Suppose you want to fetch mail for user "ashish"

Then,

     #useradd ashish

     #su ashish

     #mkdir -m 0700 ~/.getmail


Now make a new file,

     #vi ~/.getmail/getmailrc

===========================

[retriever]
type = SimplePOP3Retriever
server = <external Mail Server IP>
username =  username@domain_name # add username before @ sign
password = <Users mail password> # add password for that account

[destination]
type = MDA_external
path = /usr/sbin/sendmail
arguments = ("-i", "-bm", " @<domain_name>") # add username before @ sign
unixfrom = true

[options]
verbose = 1
read_all = false
delete = false #---------> Leave Copy on server Enabled when it's set to (False)

OR

delete_after = <days>
message_log_syslog = true

===========================

Now test below command, if it's working for that user;

     #getmail

& to make it automatic mail fetching put it in "crontab",

     #crontab -e

*/5 * * * * /usr/bin/getmail &> /dev/null


----------------------------------------------------------------------------------------------

Sample ~/.getmail/getmailrc

----------------------------------------------------------------------------------------------


#vi ~/.getmail/getmailrc


[retriever]
type = SimplePOP3Retriever
server = 70.116.111.228
username =  ashish@maildomain.in # add username before @ sign
password = ashish123 # add password for that account

[destination]
type = MDA_external
path = /usr/sbin/sendmail
arguments = ("-i", "-bm", " @maildomain.in") # add username before @ sign
unixfrom = true

[options]
verbose = 1
read_all = false
delete = false #Leave Copy on server Enabled when it's set to (False)

OR

delete_after = 30
message_log_syslog = true

----------------------------------------------------------------------------------------------


Here i have shown you simple configuration of getmail to fetch mail from External mail server to our own internal mail server. If you want to check more configuration options please visit getmail website.


_Enjoy :D

Comments

Popular posts from this blog

Recover or restore initramfs file in RHEL or CentOS 7

Space reclamation / UNMAP on RHEL or CentOS 7

How to recover /boot partition on RHEL or CentOS 7?