1

Topic: Can't Figure Out Setting up Domain Alias for MySQL

==== Required information ====
- iRedMail version: 0.8.6
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Linux/BSD distribution name and version: Ubuntu 12.04
- Related log if you're reporting an issue:
====
I'm writing a tutorial on iRedMail and want to include instructions for filtering inbound mail through mailgun.com - mailgun removes SPAM, then forwards msgs on to iRedMail server.

Mail is sent to hong2.com - the MX for hong2.com goes to mailgun.com for filtering
Mailgun forwards mail to user@inbound.hong2.com - the MX for inbound.hong2.com points to my iRedMail server

I just want <any user>@inbound.hong2.com to deliver to <any user>@hong2.com. I believe this is just a simple domain alias setting.

I keep getting this error: User unknown in virtual mailbox table;
Jun 13 07:12:15 x postfix/smtpd[9327]: connect from mail-s65.mailgun.info[184.173.153.193]
Jun 13 07:12:15 x postfix/smtpd[9327]: NOQUEUE: reject: RCPT from mail-s65.mailgun.info[184.173.153.193]: 550 5.1.0 <bounce+f3ca76.809f-jeff=inbound.hong2.com@hong2.com>: Sender address rejected: User unknown in virtual mailbox table; from=<bounce+f3ca76.809f-jeff=inbound.hong2.com@hong2.com> to=<jeff@inbound.hong2.com> proto=ESMTP helo=<mail-s65.mailgun.info>
Jun 13 07:12:15 x postfix/smtpd[9327]: disconnect from mail-s65.mailgun.info[184.173.153.193]

Could you please document the mysql domain alias manual setup more clearly? This is what I did below:

I added an entry to the alias_domain table. And, I made aliases =1 in the domain table for hong2. See further below... but nothing I do is changing the postfix error message.

>cd /etc/postfix/mysql
> for cf in $(ls *.cf); do echo ${cf}; postmap -q jeff@inbound.hong2.com mysql:./${cf}; done
Outputs this:
catchall_maps.cf
domain_alias_catchall_maps.cf
domain_alias_maps.cf
jeff@hong2.com
recipient_bcc_maps_domain.cf
recipient_bcc_maps_user.cf
relay_domains.cf
sender_bcc_maps_domain.cf
sender_bcc_maps_user.cf
sender_login_maps.cf
transport_maps_domain.cf
transport_maps_user.cf
virtual_alias_maps.cf
virtual_mailbox_domains.cf
virtual_mailbox_maps.cf

My alias domain table is:
alias_domain    target_domain    created    modified    active
inbound.hong2.com    hong2.com    0000-00-00 00:00:00    0000-00-00 00:00:00    1

My domain table is:
domain    description    disclaimer    aliases    mailboxes    maxquota    quota    transport    backupmx    defaultuserquota   
hong2.com            1    0    0    0    dovecot    0    1024   

My alias table is:
address    goto    name    moderators    accesspolicy    domain    created    modified    expired    active
postmaster@hong2.com    postmaster@hong2.com                hong2.com    2013-06-11 05:09:14    0000-00-00 00:00:00    9999-12-31 00:00:00    1

My mailbox table is:
username    password    name    language    storagebasedirectory    storagenode    maildir    quota    domain    transport    department    rank    employeeid    isadmin    isglobaladmin    enablesmtp    enablesmtpsecured    enablepop3    enablepop3secured    enableimap    enableimapsecured    enabledeliver    enablelda    enablemanagesieve    enablemanagesievesecured    enablesieve    enablesievesecured    enableinternal    enabledoveadm    enablelib-storage    lastlogindate    lastloginipv4    lastloginprotocol    disclaimer    passwordlastchange    allowedsenders    rejectedsenders    allowedrecipients    rejectedrecipients    created    modified    expired    active    local_part    bytes    messages
postmaster@hong2.com    $1xxxxxxxH4a/    postmaster    en_US    /var/vmail    vmail1    hong2.com/p/o/s/postmaster-2013.06.11.05.02.40/    100    hong2.com            normal        1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    0000-00-00 00:00:00    0            0000-00-00 00:00:00                    2013-06-11 05:09:14    0000-00-00 00:00:00    9999-12-31 00:00:00    1        0    0
jeff@hong2.com    $1$xxxxxxxhmN.    Jeff Reifman    en_US    /var/vmail    vmail1    hong2.com/j/e/f/jeff-2013.06.12.07.34.26/
jeff@hong2.com    jeff@hong2.com                hong2.com    2013-06-12 07:34:26    0000-00-00 00:00:00    9999-12-31 00:00:00    1
@hong2.com    jeff@hong2.com                    0000-00-00 00:00:00    0000-00-00 00:00:00    9999-12-31 00:00:00    1

2

Re: Can't Figure Out Setting up Domain Alias for MySQL

*) Adding a record in table "alias_domain" is enough.
*) The mail user 'username@[your_original_domain.com]' must exist first, so that 'username@[alias_domain]' will go to 'username@[original_domain]'. This is default setting configured by iRedMail.

3 (edited by newscloud 2013-06-13 16:07:59)

Re: Can't Figure Out Setting up Domain Alias for MySQL

Update: emailing jeff@inbound.hong2.com directly leads to correct delivery. But, when mailgun forwards the message to jeff@inbound.hong2.com, the message bounces with mailbox mapping error. So, please see below - I don't know how to fix the postfix error.

Thank you for the quick reply.

1) Adding a record in table "alias_domain" is enough. ==> So this is okay in my above example, right

2) The mail user 'username@[your_original_domain.com]' must exist first, so that 'username@[alias_domain]' will go to 'username@[original_domain]'. This is default setting configured by iRedMail.

-> In what table? There is a mailbox entry for jeff@hong2.com and an alias entry for jeff@hong2.com.

3) Seems like I am complying with your instructions ... so why is it bouncing the address?

p.s. I am working on a tutorial for iRedmail like this WordPress one (http://jeffreifman.com/detailed-wordpre … e-for-aws/) ... if you email me at jeff@newscloud.com, I will send you a preview of the iredmail tutorial.

4

Re: Can't Figure Out Setting up Domain Alias for MySQL

newscloud wrote:

Update: emailing jeff@inbound.hong2.com directly leads to correct delivery. But, when mailgun forwards the message to jeff@inbound.hong2.com, the message bounces with mailbox mapping error. So, please see below - I don't know how to fix the postfix error.

Show us detailed bounce message and related log in Postfix log file here, so that others can help troubleshoot.

newscloud wrote:

1) Adding a record in table "alias_domain" is enough. ==> So this is okay in my above example, right

Yes.

newscloud wrote:

2) The mail user 'username@[your_original_domain.com]' must exist first, so that 'username@[alias_domain]' will go to 'username@[original_domain]'. This is default setting configured by iRedMail.

-> In what table? There is a mailbox entry for jeff@hong2.com and an alias entry for jeff@hong2.com.

Both "alias" and "mailbox". The reason why we need an entry in "alias" table is a historical reason.

newscloud wrote:

3) Seems like I am complying with your instructions ... so why is it bouncing the address?

So, what's the bounce message?

5

Re: Can't Figure Out Setting up Domain Alias for MySQL

Thanks Zhang.

Which log file do you need - this is mail.log:

When mailgun forwards to inbound.hong2.com ->

Jun 13 08:04:31 x postfix/smtpd[9874]: connect from mail-s65.mailgun.info[184.173.153.193]
Jun 13 08:04:31 x postfix/smtpd[9874]: NOQUEUE: reject: RCPT from mail-s65.mailgun.info[184.173.153.193]: 550 5.1.0 <bounce+f3ca76.809f-jeff=inbound.hong2.com@hong2.com>: Sender address rejected: User unknown in virtual mailbox table; from=<bounce+f3ca76.809f-jeff=inbound.hong2.com@hong2.com> to=<jeff@inbound.hong2.com> proto=ESMTP helo=<mail-s65.mailgun.info>
Jun 13 08:04:31 x postfix/smtpd[9874]: disconnect from mail-s65.mailgun.info[184.173.153.193]

When I send from gmail direct to jeff@inbound.hong2.com:
Jun 13 08:03:44 x postfix/smtpd[9896]: connect from x.hong2.com[127.0.0.1]
Jun 13 08:03:44 x postfix/smtpd[9896]: 7BFF325262: client=x.hong2.com[127.0.0.1]
Jun 13 08:03:44 x postfix/cleanup[9888]: 7BFF325262: message-id=<CADB8sxQZ5VLhmdfhSA7T=qRfAFWGGnJY1a4N_5hvKvmC9P4K0Q@mail.gmail.com>
Jun 13 08:03:44 x postfix/qmgr[8762]: 7BFF325262: from=<bounce+999672.a2136-jeff=inbound.hong2.com@geogram.co>, size=3648, nrcpt=1 (queue active)
Jun 13 08:03:44 x postfix/smtpd[9896]: disconnect from x.hong2.com[127.0.0.1]
Jun 13 08:03:44 x amavis[1268]: (01268-13) Passed CLEAN, LOCAL [184.173.153.193] [209.85.220.52] <bounce+999672.a2136-jeff=inbound.hong2.com@geogram.co> -> <jeff@hong2.com>, Message-ID: <CADB8sxQZ5VLhmdfhSA7T=qRfAFWGGnJY1a4N_5hvKvmC9P4K0Q@mail.gmail.com>, mail_id: apjQtQJf+ka3, Hits: 0, size: 3030, queued_as: 7BFF325262, dkim_id=@geogram.co,jeff=newscloud.com@geogram.co, 4867 ms
Jun 13 08:03:44 x postfix/smtp[9893]: 4AA8925237: to=<jeff@hong2.com>, relay=127.0.0.1[127.0.0.1]:10024, delay=6.6, delays=1.5/0.01/0.16/4.9, dsn=2.0.0, status=sent (250 2.0.0 from MTA([127.0.0.1]:10025): 250 2.0.0 Ok: queued as 7BFF325262)
Jun 13 08:03:44 x postfix/qmgr[8762]: 4AA8925237: removed
Jun 13 08:03:44 x postfix/pipe[9897]: 7BFF325262: to=<jeff@hong2.com>, relay=dovecot, delay=0.15, delays=0.01/0.02/0/0.12, dsn=2.0.0, status=sent (delivered via dovecot service)
Jun 13 08:03:44 x postfix/qmgr[8762]: 7BFF325262: removed

6

Re: Can't Figure Out Setting up Domain Alias for MySQL

newscloud wrote:

Sender address rejected: User unknown in virtual mailbox table; from=<bounce+f3ca76.809f-jeff=inbound.hong2.com@hong2.com> to=<jeff@inbound.hong2.com>

This log makes sense.

If the Sender address is a domain hosted on your server, Postfix requires this client to perform SMTP AUTH first, after auth succeed, Postfix accepts email and sends it out. This is default setting in iRedMail, which prevents your server to be an open relay.

Both hong2.com and 'inbound.hong2.com' are hosted on your server, so Postfix will ask it to perform SMTP AUTH, but obviously, it won't do this.

7

Re: Can't Figure Out Setting up Domain Alias for MySQL

Thanks Zhang, I appreciate your help. Unfortunately, I'm still confused.

Mail is sent to jeff@hong2.com - the MX for hong2.com goes to mailgun.com service for spam filtering
Mailgun.com forwards delivery to jeff@inbound.hong2.com - the MX for inbound.hong2.com points to my iRedMail server
But the message is never received in Dovecot/Roundcube. Postfix deletes it.
Sender address rejected: User unknown in virtual mailbox table; from=<bounce+f3ca76.809f-jeff=inbound.hong2.com@hong2.com> to=<jeff@inbound.hong2.com>

Is there a way to set up iRedMail to receive the message to jeff@inbound.hong2.com as having been delivered to jeff@hong2.com?


By the way, If I send from test@gmail.com directly to jeff@inbound.hong2.com, Postfix accepts the msg and delivers it. But when Mailgun delivers forward the msg to: jeff@hong2.com to jeff@inbound.hong2.com, it fails.

8

Re: Can't Figure Out Setting up Domain Alias for MySQL

*) Your iRedMail mail server hosts both domains: inbound.hong2.com, hong2.com.
*) If email has Sender address ends with '@inbound.hong2.com', or '@hong2.com', Postfix (MTA on iRedMail) asks the client (MailGun server, in your case) to perform SMTP auth to identity itself. Obviously, MailGun won't perform SMTP AUTH for this forwarded email.

9

Re: Can't Figure Out Setting up Domain Alias for MySQL

...also adding the IP (or IPs) of mailgun.com into mynetworks (in main.cf) should solve your problem.

10

Re: Can't Figure Out Setting up Domain Alias for MySQL

camel1cz wrote:

...also adding the IP (or IPs) of mailgun.com into mynetworks (in main.cf) should solve your problem.

This did NOT fix it. Same error message. And, yes, I restarted Postfix. Thank you for suggesting it. Any other ideas?

11

Re: Can't Figure Out Setting up Domain Alias for MySQL

Zhang, thank you - is there a way to make this work?

ZhangHuangbin wrote:

*) Your iRedMail mail server hosts both domains: inbound.hong2.com, hong2.com.
*) If email has Sender address ends with '@inbound.hong2.com', or '@hong2.com', Postfix (MTA on iRedMail) asks the client (MailGun server, in your case) to perform SMTP auth to identity itself. Obviously, MailGun won't perform SMTP AUTH for this forwarded email.

12

Re: Can't Figure Out Setting up Domain Alias for MySQL

I think MailGun has many mail servers, so the IP addresses changes randomly, appending IP addresses in Postfix "mynetworks" is not that good.

Does MailGun has option to let you specify the sender which not ends with your hosted domain?

13

Re: Can't Figure Out Setting up Domain Alias for MySQL

I believe there is an issue with the mynetworks not reading the file, I have a static ip with mailgun and same issues as above.

The issue is with the sender address, and how mailgun changes.

One solution that works but its hard to configure on clients is adding a header to emails:

X-Mailgun-Native-Send: True

This make it work.