Mail being delivered to incorrect address

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Mail being delivered to incorrect address

David Hobley
Hello,

alias_maps=
virtual_transport=lmtp:unix:/kopano/dagent.sock
virtual_mailbox_domains=domain1.com, domain2.com, domain3.com
virtual_mailbox_maps=mysql:/etc/postfix/mysql-users.cf
virtual_alias_maps=hash:/etc/postfix/virtual

The virtual aliases look like:
[hidden email] user1firstname.lastname

[hidden email] user2firstname.lastname
[hidden email] user2firstname.lastname
[hidden email] user2firstname.lastname

@domain3.com user2firstname.lastname
@domain2.com user1firstname.lastname
@domain1.com user1firstname.lastname


In effect, I have 3 users created for domain1.com. A catchall for domain1 and domain2 to direct to user 1. Ignore domain3 for the time being.

For some reason though, all emails are ending up in user1’s Inbox. If I send an email from an external email address to [hidden email] it ends up in [hidden email]’s email. If I send an email to user2

Postfix logs show:
Jun 16 09:53:18 kopano postfix/smtp[8735]: 9665C6C28C5: to=[hidden email], orig_to=[hidden email], relay=127.0.0.1[127.0.0.1]:10024, delay=3.9, delays=2.2/0.01/0/1.6, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 4DFA46C28E1)
Reply | Threaded
Open this post in threaded view
|

RE: Mail being delivered to incorrect address

David Hobley
Sorry, that got sent prior to my completing the email. I'll try again.

/etc/postfix/main.cf
alias_maps =
append_dot_mydomain = no
biff = no
compatibility_level = 2
content_filter = smtp-amavis:[127.0.0.1]:10024
inet_interfaces = all
inet_protocols = ipv4
mailbox_size_limit = 0
message_size_limit = 40960000
milter_default_action = accept
milter_protocol = 6
mydestination =
myhostname = mail.domain2.com
mynetworks = 127.0.0.0/8 192.168.18.0/24 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
non_smtpd_milters = $smtpd_milters
policyd-spf_time_limit = 3600
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_CApath = /etc/ssl/certs
smtp_tls_mandatory_protocols = !SSLv2,!SSLv3
smtp_tls_protocols = !SSLv2,!SSLv3
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name
smtpd_helo_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_helo_hostname, reject_invalid_helo_hostname, reject_unknown_helo_hostname, permit
smtpd_milters = local:/opendkim/opendkim.sock,local:/opendmarc/opendmarc.sock
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_invalid_helo_hostname, reject_non_fqdn_helo_hostname, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unauth_destination, reject_unauth_pipelining, reject_rbl_client zen.spamhaus.org, reject_rbl_client bl.spamcop.net, reject_rbl_client b.barracudacentral.org, reject_rbl_client dnsbl.sorbs.net, reject_unauth_destination, reject_unknown_client_hostname, reject_unknown_sender_domain, check_policy_service unix:private/policyd-spf, permit
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_tls_cert_file = /etc/kopano/ssl/cacert.pem
smtpd_tls_key_file = /etc/kopano/ssl/server.pem
smtpd_tls_security_level = may
tls_random_source = dev:/dev/urandom
virtual_alias_domains =
virtual_alias_maps = hash:/etc/postfix/virtual
virtual_mailbox_domains = domain1.com, domain2.com, domain3.com
virtual_mailbox_maps = mysql:/etc/postfix/mysql-users.cf
virtual_transport = lmtp:unix:/kopano/dagent.sock


The virtual aliases look like:
[hidden email] user1firstname.lastname

[hidden email] user2firstname.lastname
[hidden email] user2firstname.lastname
[hidden email] user2firstname.lastname

@domain3.com user2firstname.lastname
@domain2.com user1firstname.lastname
@domain1.com          user1firstname.lastname


In effect, I have 3 users created for domain1.com. A catchall for domain1 and domain2 to direct to user 1. Ignore domain3 for the time being.

For some reason though, all emails are ending up in user1’s Inbox. If I send an email from an external email address to [hidden email] it ends up in user1firstname.lastname’s email. If I send an email to [hidden email] it also ends up in user1firstname.lastname's email.

Interestingly, if I remove the @domain1.com catchall in the /etc/postfix/virtual file, email gets delivered correctly to [hidden email] and [hidden email].

Postfix logs show (with the catchall):
Jun 16 09:53:18 kopano postfix/smtp[8735]: 9665C6C28C5: to=[hidden email], orig_to=[hidden email], relay=127.0.0.1[127.0.0.1]:10024, delay=3.9, delays=2.2/0.01/0/1.6, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 4DFA46C28E1)

Can anyone point me in the correct direction please. I have spent a couple of days on this trying to work out where I have gone wrong and I am mystified. Happy to provide a more full-featured config if that helps.

Cheers,
David

Reply | Threaded
Open this post in threaded view
|

Re: Mail being delivered to incorrect address

Dominic Raferd


On Thu, 18 Jun 2020 at 08:13, David Hobley <[hidden email]> wrote:
Sorry, that got sent prior to my completing the email. I'll try again.

/etc/postfix/main.cf
alias_maps =
append_dot_mydomain = no
compatibility_level = 2
...
myorigin = /etc/mailname
 
...
virtual_alias_domains =
virtual_alias_maps = hash:/etc/postfix/virtual
virtual_mailbox_domains = domain1.com, domain2.com, domain3.com
virtual_mailbox_maps = mysql:/etc/postfix/mysql-users.cf
virtual_transport = lmtp:unix:/kopano/dagent.sock

The virtual aliases look like:
[hidden email] user1firstname.lastname

[hidden email] user2firstname.lastname
[hidden email] user2firstname.lastname
[hidden email] user2firstname.lastname

@domain3.com user2firstname.lastname
@domain2.com user1firstname.lastname
@domain1.com          user1firstname.lastname


In effect, I have 3 users created for domain1.com. A catchall for domain1 and domain2 to direct to user 1. Ignore domain3 for the time being.

For some reason though, all emails are ending up in user1’s Inbox. If I send an email from an external email address to [hidden email] it ends up in user1firstname.lastname’s email. If I send an email to [hidden email] it also ends up in user1firstname.lastname's email.

Interestingly, if I remove the @domain1.com catchall in the /etc/postfix/virtual file, email gets delivered correctly to [hidden email] and [hidden email]...

Can anyone point me in the correct direction please. I have spent a couple of days on this trying to work out where I have gone wrong and I am mystified. Happy to provide a more full-featured config if that helps.

You presumably have the default setting:
append_at_myorigin = yes

Refer to http://www.postfix.org/virtual.5.html. Bear in mind that processing of virtual alias table is recursive.

So: the first time, [hidden email] is rewritten to [hidden email] (i.e. the 'myorigin' is appended, I am guessing domain1.com is set in /etc/mailname)

Because a change occurred this is then passed back through the same file and (unless you remove the @domain1.com catchall) gets rewritten to [hidden email]
Reply | Threaded
Open this post in threaded view
|

RE: Mail being delivered to incorrect address

David Hobley
In reply to this post by David Hobley


-----Original message-----

> From: Dominic Raferd <[hidden email]>
> You presumably have the default setting:
> append_at_myorigin = yes
>
> Refer to http://www.postfix.org/virtual.5.html <http://www.postfix.org/virtual.5.html>.
> Bear in mind that processing of virtual alias table is recursive.
>
> So: the first time, [hidden email] <mailto:[hidden email]>
> is rewritten to
> [hidden email] <mailto:[hidden email]>
> (i.e. the 'myorigin' is appended, I am guessing domain1.com <http://domain1.com>
> is set in /etc/mailname)
>
> Because a change occurred this is then passed back through the same file and
> (unless you remove the @domain1.com <http://domain1.com> catchall) gets rewritten
> to
> [hidden email] <mailto:[hidden email]>

Ah. That makes sense; because I am using virtual users, I guess postfix doesn't know when to stop.
I added in:

[hidden email] [hidden email]
[hidden email] [hidden email]

which are the actual end results and that catches that final rewrite. I realise the first one isn't strictly necessary given the catchall; but just for consistency!

Thanks - that was a great help.

Cheers,
David