FreeBSD & Jails: Send mail through Postfix in Jail

freebsdhostjailpostfixsendmail

I have FreeBSD 10.2 and I'm using several Jails, one of them has Postfix installed.

I want my other jails and my host system to use the local Postfix installation in the Jail. They should use sendmail to submit their mails to the Postfix Jail.

What would be the proper setup in the other Jails and the Host?

I already can send mails from within the Postfix jail and the host.

In the Host I have set in /etc/mail/mailertable:

xxx.yy  smtp:mail.xxx.yy
*.xxx.yy    smtp:mail.xxx.yy

I also have a /etc/mail/sendmail.mc (which I'm not sure if I will really need it and if it's correct though) in the host:

include(`/usr/share/sendmail/cf/m4/cf.m4')dnl
OSTYPE(freebsd6)dnl
DOMAIN(generic)dnl
FEATURE(access_db, `hash -o -T<TMPF> /etc/mail/access')dnl
FEATURE(blacklist_recipients)dnl
FEATURE(local_lmtp)dnl
FEATURE(mailertable, `hash -o /etc/mail/mailertable')dnl
FEATURE(virtusertable, `hash -o /etc/mail/virtusertable')dnl
define(`SMART_HOST', `[10.0.0.3]')dnl
define(`MAIL_HUB', `[10.0.0.3]')dnl
MASQUERADE_AS(`xxx.yy')dnl
FEATURE(`masquerade_envelope')dnl
GENERICS_DOMAIN(host.xxx.yy HOST)dnl
FEATURE(genericstable)dnl
define(`confCW_FILE', `-o /etc/mail/local-host-names')dnl
DAEMON_OPTIONS(`Name=IPv4, Family=inet')dnl
define(`confBIND_OPTS', `WorkAroundBrokenAAAA')dnl
define(`confNO_RCPT_ACTION', `add-to-undisclosed')dnl
define(`confPRIVACY_FLAGS', `authwarnings,noexpn,novrfy')dnl
define(`confDONT_PROBE_INTERFACES',`True')dnl
define(`confDEF_CHAR_SET',`ISO-8859-1')dnl
MAILER(local)dnl
MAILER(smtp)dml

In the jails I have set sendmail_enable="NO" in rc.conf

However, when I try to send an email from a jail I get:

Jan  5 12:54:52 push sendmail[83676]: u05BsqB6083676: from=root, size=55, class=0, nrcpts=1, msgid=<201601051154.u05BsqB6083676@push.xxx.yy>, relay=root@localhost
Jan  5 12:54:52 push sm-mta[83677]: STARTTLS=server, relay=push [10.0.0.12], version=TLSv1/SSLv3, verify=NO, cipher=DHE-RSA-AES256-GCM-SHA384, bits=256/256
Jan  5 12:54:52 push sendmail[83676]: STARTTLS=client, relay=[127.0.0.1], version=TLSv1/SSLv3, verify=FAIL, cipher=DHE-RSA-AES256-GCM-SHA384, bits=256/256
Jan  5 12:54:52 push sm-mta[83677]: u05Bsq42083677: from=<root@push.xxx.yy>, size=404, class=0, nrcpts=1, msgid=<201601051154.u05BsqB6083676@push.xxx.yy>, proto=ESMTP, daemon=Daemon0, relay=push [10.0.0.12]
Jan  5 12:54:52 push sendmail[83676]: u05BsqB6083676: to=mail@xxx.yy, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30055, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (u05Bsq42083677 Message accepted for delivery)
Jan  5 12:54:52 push sm-mta[83679]: u05Bsq42083677: to=<mail@xxx.yy>, ctladdr=<root@push.xxx.yy> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=30404, relay=mail.xxx.yy. [XX.XX.XX.XX], dsn=4.0.0, stat=Deferred: Connection refused by mail.xxx.yy.

In the Postfix jail I don't get any logs about this.

Best Answer

Fix your Postfix jail. Not having logs is an error in itself.

Also your log says Connection refused by mail.xxx.yy -- so your relay setup seems to be working but you cannot connect to Postfix. Maybe it does not bind to the right IP?

Related Topic