0
votes

What I've got

I'm testing postfix on Virtualbox. Initially I had success by passing incoming mail (towards my domain) to a pipe (approach 1 from this answer https://superuser.com/a/1490699 ) and letting outgoing mail send as normal.

Now I've switched my postfix config to use virtual mailbox features (still on Virtualbox) so I can use Mysql to query that the domain and user exists before accepting mail. With config such as:

virtual_transport = myhook:dummy
    
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf

all working well when testing via postmap -q, and I removed my domain from "mydestination" to ensure mail is not transported to local.

The Issue

I've followed a lot of guides

https://www.linode.com/docs/guides/email-with-postfix-dovecot-and-mysql/ https://wiki.gentoo.org/wiki/Complete_Virtual_Mail_Server/Postfix_to_Database

However these guide are made with Dovecot in mind and I wont be using that.

When sending mail via command line to another user that is found within the virtual mailboxes I get the following error

to=<[email protected]>, orig_to=<me>, relay=none, delay=36, delays=36/0.02/0.05/0, dsn=5.4.4, status=bounced (Host or domain name not found. Name service error for name=laravel8.test type=AAAA: Host not found)

This is despite the domain appearing in virtual_mailbox_domains. Changing to ipv4 had no change

I read that this can be due to Postfix not using /etc/hosts (which points laravel8.test to 127.0.0.1) so I added the following lines to main.cf

lmtp_host_lookup = native
smtp_host_lookup = native

But now I get this error:

 to=<[email protected]>, relay=none, delay=0, delays=0/0/0/0, dsn=5.4.6, status=bounced (mail for laravel8.test loops back to myself)

Yes, Is that not what I want? I want mail sent to another user to then transport this mail to my pipe as declared in virtual_transport.

No matter what I do I only seem to encounter more issues.

Please help if possible.

1

1 Answers

0
votes

Issue seems to be

/etc/postfix/mysql-virtual-mailbox-domains.cf

was

user = root
password =
hosts = 127.0.0.1
dbname = laravel
query = SELECT domain FROM mailbox WHERE domain='%d' LIMIT 1

When it should be

user = root
password =
hosts = 127.0.0.1
dbname = laravel
query = SELECT domain FROM mailbox WHERE domain='%s' LIMIT 1

I got really confused about when and where %s should be used or %d and %u. Here postfix only sends domain to this mysql query so must be whole string as %s