If you need a simple MTA that will send mail across the internet, sendmail is a commonly used provider. It ships with most linux distributions and can be configured with relative ease. The other competing out of the box solution is postifix. Which on to pick? Probably postfix, but I was in a hurry and dived in to how to configure sendmail first. I guess eventually I’ll get around to setting up postfix.
Open up the sendmail configuration file:
[root@bedrock ~]# vi /etc/mail/sendmail.mc
Uncomment the flag that bars accepting unresolvable domains:
dnl # We strongly recommend not accepting unresolvable domains if you want to
dnl # protect yourself from spam. However, the laptop and users on computers
dnl # that do not have 24x7 DNS do need this.
dnl #
dnl # FEATURE(`accept_unresolvable_domains')dnl
dnl #
FEATURE(`relay_based_on_MX')dnl
to
FEATURE(`accept_unresolvable_domains') dnl
comment out the localhost mapping so sendmail will listen to all lookups
dnl # The following causes sendmail to only listen on the IPv4 loopback address
dnl # 127.0.0.1 and not on any other network devices. Remove the loopback
dnl # address restriction to accept email from the internet or intranet.
dnl #
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
to
dnl # DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA') dnl
This will allow sendmail to relay emails generated from domains that can’t be resolved. Like a computer on your network with an IP address, and no domain name attached to it. Flagging this means it will accept requests from anyone that tells it to send email. This is something spammers would love to abuse so we can stop them by setting up who is allowed to generate emails -
[root@bedrock ~]# vi /etc/mail/access
# By default we allow relaying from localhost...
Connect:localhost.localdomain RELAY
Connect:localhost RELAY
Connect:127.0.0.1 RELAY
192.168.1 RELAY
Assuming I only want anything on my local network (ie: 192.168.1.x) to be allowed to send email, I can add that last line to configure sendmail to allow emails from my network to relay messages to the outside world.
Now, I should be able to use this smtp server to send email to anyone I want. Don’t break any laws. You’ve been warned.
Related posts: