Install and get e-mail with fetchmail daemon (2024)

()

fetchmail daemon pick up e-mails and forward to local mailbox

fetchmail is a daemon for retrieving and forwarding e-mail; the Unix pioneer retrieves e-mail from remote mail servers and forwards them to the delivery system. The mail can then be retrieved using normal e-mail user agents such as mutt, elm, or mail.

What is fetchmail ?

The fetchmail e-mail program can run in daemon mode to repeatedly queries one or more systems at a given interval, it collects e-mails from servers that support all common e-mail retrieval services, such as POP3 and IMAP, also support the ESMTP-ETRN extension and the ODMR protocols.

This article describes how to use fetchmail on a CentOS smart host with Postfix. The e-mail from external mail service providers is retrieved and the recipient is redirected to the mailbox server that receives e-mail from the smart host. Mail accounts do not require forwarding, and the smart host also scans the e-mail for viruses and SPAM before they are delivered to the user’s mailbox.

Install fetchmail e-mail daemon

To install fetchmail e-mail daemon on CentOS 7, the extras repository is required, if not already available.

$ wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm$ sudo rpm -Uvh epel-release-latest-7*.rpm

The fetchmail daemon can be installed from the CentOS Extras repository.

$ yum -y install fetchmail

We create the fetchmail configuration file for the daemon under /etc/sysconfig.

# This file will be used to declare some vars for fetchmail## Uncomment the following if you dont want localized log messages# export LC_ALL=C# Declare here if we want to start fetchmail. 'yes' or 'no'START_DAEMON=yes

Copy Paste /etc/sysconfig/fetchmail

The fetchmail e-mail daemon Init script is created, here for a CentOS host on this the Postfix MTA is already running. As root with vi /etc/rc.d/init.d/fetchmaild

#!/bin/sh# chkconfig: 35 99 00# description: Start and stop fetchmail. /etc/init.d/functionsstart() { echo "Starting fetchmaild..." su fetchmail -s /bin/sh -c "fetchmail -vv -d 900 -a -f /etc/fetchmailrc -L /var/log/fetchmail" }stop() { echo "Shutting down fetchmaild..." su fetchmail -s /bin/sh -c "fetchmail --quit" }case "$1" in start) start ;; stop) stop ;; restart) stop start ;; *) echo "Usage: $0 {start|stop|restart}" ;;esacexit 0

Copy Paste /etc/rc.d/init.d/fetchmail
Make the init script executable.

$ chmod 0755 /etc/rc.d/init.d/fetchmaild

Create the global fetchmailrc Recource configuration for operation as a daemon.

set daemon 900set no syslogset logfile /var/log/fetchmailset postmaster "postmaster"set no bouncemailset no spambounceset properties ""poll mail.foo.org with proto POP3user 'joe@foo.org' there with password 'secret' is joe.office@foo.com here options fetchall nokeep ssl smtphost localhost

Copy Paste /etc/fetchmailrc

For each mail server fetchmail retrieved from this e-mail, a poll line is created. The aim is to retrieve the external mailbox from joe@foo.org to the POP3 Server mail.foo.org and to be delivered to the user joe.office@foo.com via the localhost via Postfix to the Mailbox Server. To prevent logging in maillog, log is made in fetchmail instead of it.

Possibilities with fetchmail

fetchmail offers a number of syntactic subtleties to make it easier for fetchmailrc to read files. For example, the words and, with, has, wants, and options are ignored by fetchmail, as well as punctuation marks. While it is possible to provide credentials for a server on a row, common configurations are specified over a number of different lines. fetchmail is insensitive to whitespace unless the argument is in quotation marks and closing characters.

fetchmail options

There are fetchmail provide several options for the Poll statement (e.B. nofetchall (default), fetchall, keep, nokeep ).The meanings are as follows:

nofetchall: retrieve only new messages (default). Unless otherwise specified (i.e. fetchall, keep ), this means nofetchall.
fetchall: get all messages, seen or not.keep.
keep: do not delete any message on server.
nokeep: delete the read messages on server.

Create the fetchmail user and group and set the rights.

$ groupadd -r fetchmail$ useradd -r -m -g fetchmail -s /sbin/nologin fetchmail$ chown fetchmail /etc/fetchmailrc$ chmod 0600 /etc/fetchmailrc$ touch /var/log/fetchmail$ chown fetchmail:fetchmail /var/log/fetchmail$ chmod 0600 /var/log/fetchmail

The fetchmail e-mail daemon starts.

$ /etc/rc.d/init.d/fetchmaild start

After changing the fetchmailrc configuration, the systemd daemon have to restart.

$ systemctl daemon-reload

fetchmail check

You can check the fetchmail e-mail daemon conversation to server with run the following command:

$ fetchmail -vv -N --ssl -p pop3 -P 995 -ujoe@foo.org mail.foo.org

Test the fetchmailrc configuration file.

$ fetchmail -v -a -k -f /etc/fetchmailrc

Check the fetchmail e-mail daemon process.

$ ps -ef | grep -v grep | grep fetchmail

The output may look something like this:

fetchma+ 4126 1 0 19:19 ? 00:00:00 fetchmail -vv -d 900 -a -f /etc/fetchmailrc -L /var/log/fetchmailroot 6488 3985 0 16:25 pts/0 00:00:00 su fetchmail

fetchmail daemon logging

fetchmail e-mail daemon logging now takes place in the fetchmail file.

$ tail -f /var/log/fetchmail

The fetchmail e-mail daemon man page outputs a lot of information.

$ man fetchmail

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Related posts:

  • How to fetchmail on Debian 11
  • Mail Server FQDN 450 Helo command rejected: Host not found
  • send mail mailx command
Install and get e-mail with fetchmail daemon (2024)

FAQs

How to install Fetchmail? ›

Configuration
  1. Step 1: create user. Fetchmail does not need root or normal user privileges to run so it is suggested to create an unprivileged user and group for daemon based fetchmail configurations. ...
  2. Step 2: create directories. ...
  3. Step 3: set-up configuration. ...
  4. Step 4: starting the daemon. ...
  5. Step 5: testing the deamon.

How to use fetchmail command line? ›

Using Fetchmail
  1. Confirm that the polling interval is configured in the ~/. fetchmailrc by the line daemon 600 (ie. ...
  2. Confirm that the polling option fetchlimit 400 is set in the ~/. ...
  3. Start fetchmail using the same command as above, but omit the -d0 switch.
Feb 3, 2020

What is the use of Fetchmail? ›

The Fetchmail program can retrieve mail using the POP2, POP3 and IMAP protocols, one of which will be supported by almost all mail servers. It can also use the ETRN mode of the SMTP protocol to force a mail server to deliver all queued messages that are awaiting delivery to your system.

What is Fetchmail Linux? ›

Fetchmail is an open-source software utility for POSIX-compliant operating systems which is used to retrieve e-mail from a remote POP3, IMAP, or ODMR mail server to the user's local system.

How to install plugin installer? ›

To install the plugin, you visit the website of the plugin's developer and click on a link that will download the installer for the plugin you have selected. You can save the installer to an easy to find location such as the Desktop or a specific folder you have created to organize all of your downloads.

How to install module pip? ›

Install Modules with pip
  1. Ensure the pip module is already installed. ...
  2. Verify the release of pip to ensure it is installed correctly. ...
  3. Install the new Python module using the command pip install <module-name> . ...
  4. To list all installed Python modules and packages, use the pip list command.
Jan 28, 2022

What is the folder option in fetchmail? ›

The folder option points out which mail folder you are interested in downloading (INBOX and Spam are usually more than enough), while nokeep means you do not want to keep a copy of your messages on the server. For more information you can read fetchmail manual (using the command line 'man 1 fetchmail').

What is the keep option in fetchmail? ›

(Keyword: keep) Keep retrieved messages on the remote mailserver. Normally, messages are deleted from the folder on the mailserver after they have been retrieved. Specifying the keep option causes retrieved messages to remain in your folder on the mailserver.

How to use the command-line? ›

Click on Command Prompt in the Windows System section. Hold the special Windows key on your keyboard and press the "X" key. Choose "Command Prompt" from the pop-up menu. Hold the Windows key and press the "R" key to get a "Run" window.

What is fetch limit in Fetchmail? ›

fetchlimit <number> — Only allows a certain number of messages to be retrieved before stopping. flush — Tells Fetchmail to delete all previously viewed messages in the queue before retrieving new messages. limit <max-number-bytes> — Allows you to specify that only messages below a particular size may be retrieved.

What is Postfix in a mail server? ›

Postfix is a hugely-popular Mail Transfer Agent (MTA) designed to determine routes and send emails.

What is the usage of Mailq? ›

The mailq and MAILQ commands print a list of messages that are in the mail queue. The first line printed for each message shows: The internal identifier used on this host for the message with a possible status character. The size of the message in bytes.

How to use mailq command in Linux? ›

Description. The mailq command prints a list of messages that are in the mail queue. The mailq command is the same as the sendmail -bp command. Specify the -v flag to display message priority.

How does Linux sendmail work? ›

Sendmail takes each recipient address and attaches them to the body and header file and then sends the message to the specified recipient. The outgoing mail server is unaware of the recipient's existence, so any issues with the message such as an incorrect email account will result in the message being returned.

What is muffin Linux? ›

Muffin is a window manager performing compositing as well based on GTK+ and Clutter and used in Cinnamon desktop environment. This package contains the core binaries.

How to install efcore? ›

Visual Studio Package Manager
  1. Go to Tools » NuGet Package Manager » Manage NuGet Packages For Solution.
  2. Ensure that Browse is selected and type "entityframeworkcore" into the search box.
  3. Click on the provider that you want to install. ...
  4. Check the project that you want to install the package into, then click Install.
Feb 20, 2023

How to install rJava? ›

Procedure
  1. At the command prompt, type install. packages("rJava") . ...
  2. At the command prompt, type library(rJava) . ...
  3. At the command prompt, type searchpaths() .

How to install ADFDI plugin? ›

Install the Desktop Integration Add-In
  1. Sign into your computer with your account.
  2. Close Excel.
  3. Click Navigator > Tools > Download Desktop Integration to download the installer file.
  4. Run the adfdi-excel-addin-installer-current-user. ...
  5. Run Excel once to complete the installation.

References

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Mrs. Angelic Larkin

Last Updated:

Views: 5319

Rating: 4.7 / 5 (47 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Mrs. Angelic Larkin

Birthday: 1992-06-28

Address: Apt. 413 8275 Mueller Overpass, South Magnolia, IA 99527-6023

Phone: +6824704719725

Job: District Real-Estate Facilitator

Hobby: Letterboxing, Vacation, Poi, Homebrewing, Mountain biking, Slacklining, Cabaret

Introduction: My name is Mrs. Angelic Larkin, I am a cute, charming, funny, determined, inexpensive, joyous, cheerful person who loves writing and wants to share my knowledge and understanding with you.