For a couple of projects lately, I've had to set up a Rackspace cloud server with enough email capacity to send emails and to receive them to be processed by a script. Here are the steps I've followed:
- Edited
/etc/aliases
to include the new email address, piped to the script that will process the emails, then runnewaliases
to load these aliases. - Ran
hostname "[new-hostname]"
, which should change the setting without requiring a restart. - Installed postfix with
yum install postfix
, and ranchkconfig postfix on
so that the process starts (and restarts on reboot). - Also installed telnet and mailx for testing tools.
- Edit settings in
/etc/postfix/main.cf
and then restart postfix with/etc/init.d/postfix restart
- myhostname
- mydomain
- inet_interfaces = all
Testing tools
Send a test message from the command line
mail address@example.com Subject: test email from democloud.com test body of the email. . Cc:
Connect to the mail server using telnet
telnet 127.0.0.1 25
Iptables
In order to have the right ports open, here are the iptables commands that I used:
iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -i ! lo -d 127.0.0.0/8 -j REJECT iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A OUTPUT -j ACCEPT iptables -A INPUT -p tcp --dport 80 -j ACCEPT iptables -A INPUT -p tcp --dport 443 -j ACCEPT iptables -A INPUT -p tcp --dport 25 -j ACCEPT iptables -A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT iptables -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT iptables -A INPUT -j REJECT iptables -A FORWARD -j REJECT
After verifying that this worked, I saved the iptables settings so they'd run on restart: /etc/init.d/iptables save
.
- Login to post comments