Send e-mails from local Postfix to local Exim on same host

Written by - 0 comments

Published on - Listed in Linux Internet Mail


Today I had to figure out, how an Atmail server, which uses Exim as mail server process, can accept local e-mails, e.g. sent through mailx.
Postfix is also installed on the same machine and Postfix is called from the system. But even when I configured Postfix to use the local ip and the exim port, the mail was rejected by exim with the following error:

Oct 25 12:49:46 atmail postfix/smtp[5513]: CD2CF41791: to=, relay=192.168.23.23[192.168.23.23]:25, delay=0.11, delays=0.01/0/0.03/0.07, dsn=5.0.0, status=bounced (host 192.168.23.23[192.168.23.23] said: 550-Verification failed for 550-Unrouteable address 550 Sender verify failed (in reply to RCPT TO command))

The problem is, that Atmail/exim checks if the sender address exists in the atmail database and/or if the sender address is valid. But as I'm on the same server I don't really care about verification and just want exim to accept the mail.

After a lot of try'n'err I finally got it working with the following configuration.

1. Set up Postfix as "local mailserver" besides Atmail/Exim but let it run under a different port.
Port 25 is already in use by Atmail/Exim, therefore the listening port needs to be changed in /etc/postfix/master.cf:

#smtp      inet  n       -       n       -       -       smtpd # was
2525      inet  n       -       n       -       -       smtpd

In the very first (not commented-out) line is the standard listening definition. By default Postfix should listen on the smtp port, which is 25. But in this case I replaced smtp by "2525".

2. Make some Postfix modifications.
If not already done, set the correct hostname (fqdn) in Postfix's configuration (main.cf):

myhostname = mymailserver.example.com

Also set the relayhost to the same IP-address as this server (localhost or 127.0.0.1 won't work) with port 25 (= Exim):

relayhost = 192.168.23.23:25

Then start Postfix and verify the listening ports:

[root@mymailserver]# /etc/init.d/postfix start

[root@mymailserver]# netstat -lntp | grep 25
tcp        0      0 0.0.0.0:25                  0.0.0.0:*    LISTEN      5081/exim          
tcp        0      0 127.0.0.1:2525              0.0.0.0:*    LISTEN      5711/master

3. Edit the Exim configuration file.
Add a line which defines the server's IP address in the acl_check_rcpt part but, very important, BEFORE the # part.

acl_check_rcpt:

  # Accept if the source is local SMTP (i.e. not over TCP/IP). We do this by
  # testing for an empty sending host field.

  accept  hosts = :
 
  accept  hosts = 192.168.23.23

[...]

#
# Deny unless the sender address can be verified.
require verify = sender
#

In the case of Atmail, this Exim configure file is found in /usr/local/atmail/mailserver/configure.
After this, restart the Exim process:

pkill -HUP exim

4. Send a local e-mail and check logs.

[root@mymailserver]# echo "This is a testmail from Postfix to Exim on same server" | mailx -s "Mailserver-Talk" user@example.com

[root@mymailserver]# tail /var/log/mail.log
Oct 25 13:22:48 mymailserver postfix/pickup[5713]: 91D5241791: uid=0 from=
Oct 25 13:22:48 mymailserver postfix/cleanup[5757]: 91D5241791: message-id=<20121025132248.91D5241791@mymailserver.example.com>
Oct 25 13:22:48 mymailserver postfix/qmgr[5714]: 91D5241791: from=, size=513, nrcpt=1 (queue active)
Oct 25 13:22:49 mymailserver postfix/smtp[5759]: 91D5241791: to=, relay=192.168.23.23[192.168.23.23]:25, delay=0.46, delays=0.04/0.01/0.03/0.39, dsn=2.0.0, status=sent (250 OK id=1TRNOa-0001Uu-L8)
Oct 25 13:22:49 mymailserver postfix/qmgr[5714]: 91D5241791: removed

[root@mymailserver]# tail /usr/local/atmail/mailserver/spool/log/mainlog
2012-10-25 13:22:49 1TRNOa-0001Uu-L8 <= root@mymailserver.example.com H=mymailserver.example.com (mymailserver.example.com) [192.168.23.23] P=esmtp S=1448 id=20121025132248.91D5241791@mymailserver.example.com
2012-10-25 13:22:49 1TRNOa-0001Uu-L8 => user R=mysql_user T=mysql_delivery
2012-10-25 13:22:49 1TRNOa-0001Uu-L8 Completed

Maybe there's a simpler or better solution to that, but as I'm not at all an Exim dude, I'm already happy that it works. If you do have a better solution, please comment.


Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.

RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   OpenSearch   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder