After a few years of using SME server and its mail functionality I always had to live with this small security risk. Now that I have built a mail server from scratch and understand its back-end a lot more I can now contribute this jem back to the community.
I would not be surprised if this has already been talked about and resolved but wanted to share my solution with you all.
Even currently you are able to change the FROM address in your mail client and send emails as ANYONE else. Now with the changes made we get the following error on server and on the client (Thunderbird).
"NOQUEUE: reject: MAIL from unknown[192.168.220.1]: 553 5.7.1 <alvin@domain.co.nz>: Sender address rejected: not owned by user lewis@domain.co.nz; from=<alvin@domain.co.nz> proto=ESMTP helo=<[192.168.220.1]>"
It was as easy as this:
nano /etc/postfix/master.cf
-o smtpd_sender_restrictions=reject_authenticated_sender_login_mismatch
nano /etc/postfix/main.cf
smtpd_sender_login_maps = proxy:ldap:/etc/postfix/ldap_virtual_recipients.cf proxy:ldap:/etc/postfix/ldap_virtual_aliases.cf
The following cf files I designed for a different ldap back-end should be easily adjusted to SMEs with very little effort.
I will now post the files:
nano /etc/postfix/ldap_virtual_aliases.cf
bind = yes
bind_dn = cn=LDAP_AUTH,cn=Users,dc=domain,dc=co,dc=nz
bind_pw = password
server_host = ldap://smeserver:389
search_base = dc=domain,dc=co,dc=nz
domain = domain.co.nz
query_filter = (&(otherMailbox=%s))
result_attribute = userPrincipalName
start_tls = no
version = 2
nano /etc/postfix/ldap_virtual_recipients.cf
bind = yes
bind_dn = cn=LDAP_AUTH,cn=Users,dc=domain,dc=co,dc=nz
bind_pw = password
server_host = ldap://smeserver:389
search_base = domain.co.nz
query_filter = (&(userPrincipalName=%s)(objectClass=person)(!(userAccountControl=514)))
result_attribute = userPrincipalName
start_tls = no
version = 2
If I get some feedback saying this has already been implemented or not that would be great as I am willing to put some time adjust this for the current SME version.
Thanks All
Lewis