Gentoo Archives: gentoo-user

From: kashani <kashani-list@××××××××.net>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Setting up SMTP relay
Date: Sat, 22 Jan 2011 22:02:45
Message-Id: 4D3B53AC.904@badapple.net
In Reply to: [gentoo-user] Setting up SMTP relay by Alex Schuster
1 On 1/22/2011 1:34 PM, Alex Schuster wrote:
2 > Hi there!
3 >
4 > On my desktop PC, I have set up ssmtp with access data for my mail
5 > server, so things like smartmontools or portage can send me emails.
6 >
7 > This is working fine. But there are other PCs in the LAN, which I would
8 > also like to get status emails from. Being not the only one with root
9 > access there, I do not want to duplicate the ssmtp setup because of the
10 > password stored in ssmtp.conf.
11 >
12 > Is there an easy solution? Like setting up a simple SMTP server on my
13 > desktop PC, that accepts connections from the LAN and forwards mails to
14 > my external mail server?
15 >
16 > I once had courier running, but did not really understand the
17 > configuration, and would not really like to set it up again. Or dovecot,
18 > which I heard good things about, so I would prefer it now. But maybe the
19 > default configuration only needs few changes for my purpose? Or maybe
20 > there is another simple tool that does just what I want?
21 >
22 > It's nothing important, so if there's no simple solution, I'll just skip
23 > this and check the logs from time to time.
24 >
25 > Wonko
26 >
27
28 I handle it with Postfix. Dovecot is only imap and won't accept main
29 directly.
30
31 1. install postfix with USE sasl or devecot-sasl, I don't believe it
32 matters which. Add the following lines to the bottom of
33 /etc/postfix/main.cf and fill in your hostname, domain, etc as needed.
34
35 # local settings
36 myhostname = host.domain.com
37 mydomain = domain.com
38 myorigin = $myhostname
39 inet_interfaces = all
40 mydestination = $myhostname, localhost.$mydomain, localhost
41 mynetworks_style = subnet
42 mynetworks = 127.0.0.0/8 10.19.20.0/24
43
44 smtpd_recipient_restrictions =
45 # reject_non_fqdn_recipient
46 # reject_non_fqdn_sender
47 # reject_unknown_recipient_domain
48 permit_mynetworks
49 reject_unauth_destination
50 permit
51
52 I commented out some of the checks above. Enable them if they'll work in
53 your environment. I recommend at least reject_unknown_recipient_domain
54 which doesn't allow recipients to domains that don't exist.
55
56 2. run sudo newaliases
57 Postfix bitches if the /etc/mail/aliases.db doesn't exist and will hang
58 on start.
59
60 3. Verify postfix works, isn't complaining in the logs, etc.
61 Make sure it's up and running. That you can telnet to port 25 from
62 another machine and even send to a local user on your machine.
63
64 4. Add the user/pass stuff to the bottom of /etc/postfix/main.cf
65
66 # relay host and credentials
67 relayhost = [my.external.relayhost.com]
68 smtp_sasl_auth_enable = yes
69 smtp_sasl_password_maps = hash:/etc/postfix/sasl.passwd
70 smtp_sasl_mechanism_filter = digest-md5
71 smtp_sasl_security_options = noanonymous
72
73 /etc/postfix/sasl.passwd
74 [my.external.relayhost.com] myusername@×××××××××.com:my_secure_passwd
75
76 sudo postmap /etc/postfix/sasl.passwd
77
78 sudo /etc/init.d/postfix restart
79
80 Things to remember. You need to restart Postfix is your change the
81 password because it caches it. Also the relayhost name needs to match
82 *exactly* between the passwd file and main.cf.
83
84 5. Once you're this far it's time to test all the way through.
85
86 make sure you can send from the localhost machine
87 sendmail -v some@×××××××.com
88 .
89
90 Once you're sure that works test from another machine on the network.
91 Ideally it should just work if you've done all the steps.
92
93 kashani

Replies

Subject Author
Re: [gentoo-user] Setting up SMTP relay Alex Schuster <wonko@×××××××××.org>