Showing posts with label Postfix. Show all posts
Showing posts with label Postfix. Show all posts

Saturday, 16 July 2011

SMTP -- Configure an MTA to forward (relay) email through a smart host

This is actually quite simple. You need to modify the following line in the postfix config file (/etc/postfix/main.cf):
relayhost = 10.168.20.227
This will relay emails to host 10.168.20.227, which means that this host needs to be configured as Postfix server, see my previous post here.

Note that you still need to change other configuration settings as detailed in my previous post.

Saturday, 9 July 2011

SMTP -- Configure a mail transfer agent (MTA) to accept inbound email from other systems

Postfix is normally installed by default, but just in case it isn't, you can install it with:
yum install postfix mailx -y
mailx is useful to test that you have configured Postfix correctly. You will need to open port 25 for Postfix to work properly, like this:
iptables -I INPUT -p tcp --dport 25 -j ACCEPT; service iptables save
There only appears to be a single SELinux setting related to Postfix, and it seems to be switched on by default:
allow_postfix_local_write_mail_spool --> on
Make sure that Postfix will run when the server reboots and start the service:
chkconfig postfix on
service postfix start
Finally, if you want to prevent users from sending emails, you could add the following directive to the Postfix config file:
smtpd_recipient_restrictions =
        check_sender_access hash:/etc/postfix/restricted_senders
You can now add any users you want to prevent from sending email by adding them to this file like this:
 testuser@dev.com reject
The usual suspects covered let's get back to the objective. You'll need to edit the postfix configuration file (/etc/postfix/main.cf) and make sure you set and uncomment the following settings:
myhostname = redhat.dev.com
mydomain = dev.com

myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
You can now restart postfix and test your configuration remotely, see this post for details.

Sunday, 29 May 2011

Testing sending mail with Postfix

Yesterday, I was looking for a simple way of testing my installation of postfix and after a bit of digging I found the following:

telnet 10.168.20.229 25
Trying 10.168.20.229...
Connected to 10.168.20.229.
Escape character is '^]'.
220 RHEL6KSTest1.dev.com ESMTP Postfix
EHLO hostname
250-rh.dev.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
MAIL FROM: crazy@dev.com
250 2.1.0 Ok
RCPT TO: loco@dev.com
250 2.1.5 Ok
DATA
354 End data with .
This is a test email
.
250 2.0.0 Ok: queued as B8EF51A4D
quit

You might need to install telnet (yum install telnet)

You can then check with mail:

[root@RHEL6KSTest1 ~]# mail -u loco
Heirloom Mail version 12.4 7/29/08. Type ? for help.
"/var/spool/mail/root": 1 message
> 1 crazy@dev.com Sun May 29 12:16 15/511
&