{"id":11,"date":"2014-08-17T10:07:00","date_gmt":"2014-08-17T10:07:00","guid":{"rendered":""},"modified":"2016-02-25T18:09:01","modified_gmt":"2016-02-25T18:09:01","slug":"forwarding-emails-using-fetchmail-and-msmtp","status":"publish","type":"post","link":"https:\/\/www.root42.de\/blog\/?p=11","title":{"rendered":"Forwarding emails using fetchmail and msmtp"},"content":{"rendered":"<p>My goal here was to forward emails from my GMX freemail account to my iCloud account. Up until now, I used GMX&#8217;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.<\/p>\n<p>Hence I would only get bounce mails instead of the actual mails. Since this is no good, I set up <a href=\"http:\/\/www.fetchmail.info\/\">fetchmail<\/a> and <a href=\"http:\/\/msmtp.sourceforge.net\/\">msmtp<\/a> 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.<\/p>\n<p>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.<\/p>\n<p>So first let&#8217;s see the <span style=\"font-family: Courier New, Courier, monospace;\">~\/.fetchmailrc<\/span> (make sure to <span style=\"font-family: Courier New, Courier, monospace;\">chmod 0600<\/span> it):<\/p>\n<pre>poll pop.gmx.net<br \/>with proto POP3<br \/>user \"user@gmx.net\"<br \/>there with password \"secretpassword\"<br \/>mda \"\/usr\/bin\/msmtp -- someuser@icloud.com\"<br \/>options<br \/>no keep<br \/>ssl<br \/>sslcertck<br \/>sslcertpath \/etc\/ssl\/certs<br \/>set daemon 300<br \/><\/pre>\n<p>This will poll GMX every 300 seconds and pass the received mails to <span style=\"font-family: Courier New, Courier, monospace;\">msmtp<\/span> for delivery to <span style=\"font-family: Courier New, Courier, monospace;\">someuser@icloud.com<\/span>.<\/p>\n<p>The corresponding <span style=\"font-family: Courier New, Courier, monospace;\">~\/.msmtprc<\/span> looks like this:<\/p>\n<pre>account default<br \/>host mx6.mail.icloud.com<br \/>port 25<br \/>auto_from off<br \/>from \"user@localdomain\"<br \/>tls on<br \/>tls_starttls on<br \/>tls_trust_file \/etc\/ssl\/certs\/ca-certificates.crt<br \/>logfile ~\/.msmtp.log<br \/>domain mx.of.localdomain<br \/><\/pre>\n<p>You can find out the valid mx entries for iCloud by running <span style=\"font-family: Courier New, Courier, monospace;\">nslookup -type=mx icloud.com<\/span>.<\/p>\n<p>The settings above are assuming Debian stable. Other distributions or operating systems may have the SSL certs at different places in the file system.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My goal here was to forward emails from my GMX freemail account to my iCloud account. Up until now, I used GMX&#8217;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 &hellip; <a href=\"https:\/\/www.root42.de\/blog\/?p=11\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Forwarding emails using fetchmail and msmtp&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[11,12,10],"tags":[],"_links":{"self":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/11"}],"collection":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11"}],"version-history":[{"count":1,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/11\/revisions"}],"predecessor-version":[{"id":195,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/11\/revisions\/195"}],"wp:attachment":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}