nifty postfix stuff
Written by jlgaddis on November 23, 2006 – 8:06 pm -I’m still configuring the new Gentoo server I set up, getting all the “server-side” software installed on it that I want. One of the first things I did was (after setting the appropriate USE flags):
# emerge –unmerge ssmtpemerge postfix
I use 1and1 Internet for my hosting nowadays and all my e-mail goes through their servers. (Incoming mail actually goes to 1and1, then gets forwarding to Gmail, but I digress.) I could just as easily send all my outgoing mail through my ISP’s servers, but I don’t (don’t ask me why — I don’t know).
This is all fine and dandy, except that 1and1 requires SMTP authentication. This isn’t a problem when I’m using Thunderbird or similar that already handles that. Sometimes I just need to quickly use mail to send something to myself, however. So, I configured Postfix to relay my mail through 1and1 and to authenticate itself when doing so.
In postfix’s main.cf:
relayhost = smtp.1and1.com:587 smtpsaslauthenable = yes smtpsaslpasswordmaps = hash:/etc/postfix/saslpass smtpsaslsecurityoptions = sendercanonicalmaps = hash:/etc/postfix/sendercanonicalThe first step is to tell postfix to send any outgoing mail through 1and1’s e-mail servers (and to use port 587/TCP when doing so — to bypass any ACLs that might block port 25/TCP along the way).
The second line enabled SMTP authentication. Simple enough.
The third line tells postfix where it can find a file containing the username and password to use when attempting to authenticate to 1and1’s e-mail servers. The file looks like this:
smtp.1and1.com username:passwordThe fourth line (with the options being blank) basically tells postfix to use plain-text authentication. This is not the best, but they don’t support TLS, so we’re stuck.
The last line tells postfix that the file named /etc/postfix/sendercanonical contains a list of rewriting rules for outgoing mail. I use “jeremy@” for my e-mail, but I log into almost everything as “jlgaddis”. If I use something like the command-line “mail” program to send an e-mail, the address will be from “jlgaddis@” — not what I want. sendercanonical is simple enough, it looks like this:
jlgaddis@mydomain.com jeremy@mydomain.comWith this configured (and postfix reloaded), I can send mail out from the command line as “jlgaddis@mydomain.com” and it will appear to the recipient to be from “jeremy@mydomain.com”, which is nice if I want to receive a reply from them. =)
Tags: linux, open-source | No Comments »



