Postfix forward incoming emails to mailin

email-servernode.jspostfixsmtp

I've setup the smtp server using postfix with dovecot on mail.example.com server running on port 25.
And then I've also setup another smtp server using mailin (http://mailin.io) on mail.example.com server but running on port 10025.

The purpose of this mailin is simply to parse the incoming emails received from postfix and posts the parsed results as json through webhooks.

Since postfix don't have an api to parse the email content so that's why I'm using mailin.

On my /etc/postfix/main.cf I add this line:

relay_domains = localhost:10025 ## this is the mailin smtp server running on port 10025

Heres my maillog:

[root@mailserver ~]# tail -f /var/log/maillog
Dec 17 04:36:07 mailserver postfix/smtpd[6858]: connect from localhost[127.0.0.1]
Dec 17 04:36:07 mailserver postfix/smtpd[6858]: 6E2C21848: client=localhost[127.0.0.1]
Dec 17 04:36:07 mailserver postfix/cleanup[6868]: 6E2C21848: message-id=<20141217093607.6E2C21848@mailserver.localdomain>
Dec 17 04:36:07 mailserver postfix/qmgr[6386]: 6E2C21848: from=<arman.ortega@cebufreelancer.com>, size=506, nrcpt=1 (queue active)
Dec 17 04:36:07 mailserver postfix/smtpd[6858]: disconnect from localhost[127.0.0.1]
Dec 17 04:36:07 mailserver dovecot: lda(user1.trigger1@cebufreelancer.com): msgid=<20141217093607.6E2C21848@mailserver.localdomain>: saved mail to INBOX
Dec 17 04:36:07 mailserver postfix/pipe[6871]: 6E2C21848: to=<user1.trigger1@cebufreelancer.com>, relay=dovecot, delay=0.09, delays=0.06/0.01/0/0.02, dsn=2.0.0, status=sent (delivered via dovecot service)
Dec 17 04:36:07 mailserver postfix/qmgr[6386]: 6E2C21848: removed

As I noticed, the email was successfully sent but the mailin doesn't work.

My question is, how does the mailin receive/parse the incoming email since the postfix
was the only one who will received the email?

Can someone please explain how to do this properly?

Updated [12/17/2014]: Output from postconf -n command

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
html_directory = no
inet_interfaces = all
inet_protocols = all
mail_owner = postfix
mailbox_command = /usr/lib/dovecot/deliver
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = localhost
mynetworks_style = host
myorigin = $myhostname
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
recipient_delimiter = +
relay_domains = mysql:/etc/postfix/mysql_relay_domains.cf
sample_directory = /usr/share/doc/postfix-2.6.6/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
transport_maps = hash:/etc/postfix/transport
unknown_local_recipient_reject_code = 550
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_mailbox_domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_transport = dovecot
virtual_gid_maps = static:5000
virtual_uid_maps = static:5000

Best Answer

Disclaimer: I'm assuming that you only want to parsing email with mailin and the email won't to delivered to dovecot again.

To do that, replace the virtual_transport parameter so it becomes

virtual_transport = smtp:[127.0.0.1]:10025

That's it, instead delivering it to dovecot, postfix will pass the email to mailin via SMTP port 10025.


[UPDATE]

Based on this maillog

Dec 18 mailserver postfix/smtpd[13147]: connect from mailserver.cebufreelancer.com[9.40.80.111]
Dec 18 mailserver postfix/smtpd[13147]: 61C252F1F: client=mailserver.cebufreelancer.com[9.40.80.111]
Dec 18 mailserver postfix/cleanup[13157]: 61C252F1F: message-id=<20141219033146.61C252F1F@mailserver.localdomain>
Dec 18 mailserver postfix/qmgr[13139]: 61C252F1F: from=<ortegaaa@ph.ibm.com>, size=523, nrcpt=1 (queue active)
Dec 18 mailserver postfix/smtpd[13147]: disconnect from mailserver.cebufreelancer.com[9.40.80.111]
Dec 18 mailserver postfix/smtp[13160]: 61C252F1F: to=<user1.trigger1@cebufreelancer.com>, relay=127.0.0.1[127.0.0.1]:10025, delay=0.14, delays=0.05/0.04/0/0.04, dsn=4.1.8, status=deferred (host 127.0.0.1[127.0.0.1] said: 450 4.1.8 <user1.trigger1@cebufreelancer.com>: Recipient address rejected: Domain not found (in reply to RCPT TO command))

Postfix successfully send the message to mailin. That error

Recipient address rejected: Domain not found

came from mailin (actually from simplesmtp, an SMTP library). See the code in github.

Mailin would try to resolve the recipient domain when receiving email. When I try to resolve domain cebufreelancer.com from my VM, the result NXDOMAIN. So that's why the mailin report the error.