Configure Fetchmail to Use with Gmail and Hotmail

Fetchmail is a service that allows you to forward emails from multiple mailboxes in multiple domains to one mailbox. To use this function, fetchmail must be installed on the system.

apt install fetchmail

and configure

nano /etc/fetchmailrc
set postmaster root
set bouncemail
set syslog
set daemon 240

defaults:
batchlimit 100
antispam -1
nokeep

poll pop3.server.tld:
with nodns
with protocol pop3
user username@server.tld there
with password "mail password" is fetchmail-box@your-server.tld here
with ssl, sslcertck

# configure gmail; you need to create a password for the application in the google account settings

poll pop.gmail.com:
with nodns
with protocol pop3
user username@server.tld there
with password "aaaa bbbb cccc dddd" is fetchmail-box@your-server.tld here
with ssl

# configure hotmail

poll outlook.office365.com:
port 993
user username@hotmail.com there
with password "hotmail password" is fetchmail-box@your-server.tld here
with ssl, sslcertck
nano ~ /.fetchmailrc
poll pop3.server.tld:
with nodns
with protocol pop3
user username@server.tld there
with password "mail password" is fetchmail-box@your-server.tld here
with ssl, sslcertck

# configure gmail; you need to create a password for the application in the google account settings

poll pop.gmail.com:
with nodns
with protocol pop3
user username@server.tld there
with password "aaaa bbbb cccc dddd" is fetchmail-box@your-server.tld here
with ssl

# configure hotmail

poll outlook.office365.com:
port 993
user username@hotmail.com there
with password "hotmail password" is fetchmail-box@your-server.tld here
with ssl, sslcertck

create crontab to fetch emails every 15 minutes

*/15 * * * * /usr/bin/fetchmail