Sunday, February 16, 2014

Delivering mail from my home server to gmail

Mostly a note to myself

My ISP in Japan (OCN) blocks port 25 outgoing. It provides a relay host smtp.blue.ocn.ne.jp but it drops things if they have a dodgy looking from address. So I set up a postfix rewrite rule to make all of my mail from this server look like it was coming from my gmail account. This seems to make OCNs SMTP relay happy.

In /etc/postfix/main.cf, I added

smtp_generic_maps = regexp:/etc/postfix/generic
and that file looks like
/(.*?)@.*/ myaddress+antispamtoken+hostname-$1@gmail.com

Gmail thinks this is spam, so I had to set up a filter to automatically catch emails from myaddress+antispamtoken and mark them as not spam.

There are probably several better ways of achieving the same goal but the less I know about SMTP and MTAs the happier I am.