My goal here was to forward emails from my GMX freemail account to my iCloud account. Up until now, I used GMX’s own forwarding capability, which is a bit hidden in the filters settings. However, iCloud cranked up its spam filtering, and is now using spamhaus blacklists, which very often label the GMX forwarding servers as bad.
Hence I would only get bounce mails instead of the actual mails. Since this is no good, I set up fetchmail and msmtp on my root server to do the forwarding for me. First, fetchmail will get all mail on GMX via POP3 and pass it on to msmtp, which will in turn pass it on to the iCloud mx server.
At first I tried to deliver it via authenticated SMTP, but iCloud refuses mails sent this way, if the header from field does not contain any of your own iCloud aliases. This will most of the time be a problem, since we are trying to forward emails that were sent to you, not sent from you.
So first let’s see the ~/.fetchmailrc (make sure to chmod 0600 it):
with proto POP3
there with password "secretpassword"
mda "/usr/bin/msmtp -- firstname.lastname@example.org"
set daemon 300
This will poll GMX every 300 seconds and pass the received mails to msmtp for delivery to email@example.com.
The corresponding ~/.msmtprc looks like this:
You can find out the valid mx entries for iCloud by running nslookup -type=mx icloud.com.
The settings above are assuming Debian stable. Other distributions or operating systems may have the SSL certs at different places in the file system.