RE: Mail being delivered to incorrect address

2020-06-18 Thread David Hobley



-Original message-
> From: Dominic Raferd 
> 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, user2firstn...@domain2.com 
> 
> is rewritten to 
> user2firstname.lastn...@domain1.com 
> 
> (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 
> user1firstname.lastn...@domain1.com 
> 

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

user1firstname.lastn...@domain1.com user1firstname.lastn...@domain1.com
user2firstname.lastn...@domain1.com user2firstname.lastn...@domain1.com

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



Re: Mail being delivered to incorrect address

2020-06-18 Thread Dominic Raferd
On Thu, 18 Jun 2020 at 08:13, David Hobley 
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:
> user1firstname.lastn...@domain3.com user1firstname.lastname
>
> user2firstn...@domain2.com user2firstname.lastname
> user2firstn...@domain1.com user2firstname.lastname
> user2firstname.lastn...@domain2.com 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
> user2firstname.lastn...@domain1.com it ends up in
> user1firstname.lastname’s email. If I send an email to
> user2firstn...@domain2.com 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
> user2firstname.lastn...@domain1.com and user2firstn...@domain2.com...
>
> 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, user2firstn...@domain2.com is rewritten to
user2firstname.lastn...@domain1.com (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
user1firstname.lastn...@domain1.com


RE: Mail being delivered to incorrect address

2020-06-18 Thread 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 = 4096
milter_default_action = accept
milter_protocol = 6
mydestination =
myhostname = mail.domain2.com
mynetworks = 127.0.0.0/8 192.168.18.0/24 [:::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:
user1firstname.lastn...@domain3.com user1firstname.lastname

user2firstn...@domain2.com user2firstname.lastname
user2firstn...@domain1.com user2firstname.lastname
user2firstname.lastn...@domain2.com 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 user2firstname.lastn...@domain1.com it 
ends up in user1firstname.lastname’s email. If I send an email to 
user2firstn...@domain2.com 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 
user2firstname.lastn...@domain1.com and user2firstn...@domain2.com.

Postfix logs show (with the catchall):
Jun 16 09:53:18 kopano postfix/smtp[8735]: 9665C6C28C5: to=us...@domain1.com, 
orig_to=us...@domain1.com, 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