Check authenticated user/identity before sending

NethServer Version: 7.3.1611
Module: Mail

I have setup a NethServer with 2 user (user1, user2). After that I installe the mail module and roundcube. All works fine. Now when I log into roundcube with user1 I can create a identity with the mail address of user2. With this I can send mails as user2. Of course if the mail gets answered to it will end up in the mailbox of user2. Nevertheless it seems the mail server only checks if the user (in my case user1) is authenticated but not if the mailadress that is used to send a mail is actually “mapped” to the logged in user.

Could anybody verify if that is really true or if I messed up the settings somewhere along the way?

Thanks in advanced for your help. This is my first post so please if I made a mistake or missed to mention something do not hesitate to correct me.

PS: I use ldap for usermanagement


This is the expected behaviour. There is an enhancements request to add a checkbox somewhere to enforce sendder=authenticated user (I can’t find a reference to the issue now).

1 Like

Hi there,

Thank you for your fast reply. Do I understand that correctly that there is a request for that feature? Is it possible to sponsor such a feature?

“This is the expected behaviour”? Isn’t that very problematic that user can send mails as anyone else on the server? Seems to me like a big security risk.

Happy Weekend

We should use this postfix parameter:

I can’t find the issue, just another request: Restricting Sending external Mails

More info about that.

1 Like

Or, maybe, reject_sender_login_mismatch.
Some research is needed.

I am not sure if that solution would solve my particular problem. I will look into it a bit more. It would solve the problem at hand but for my purposes it will probably cause new ones.

The problem is that my users have multiple mailaddresses which they need to receive and send messages. So one user can have mutltiple addresses that they send from. As of now, they can send as all users.

Sidenote: I am open for discussion to sponsor such a feature. If there is a way to support the project in that way and fastforward a featuer I need then I am very open to it.

1 Like

Thanks for your willingness, we don’t have a clear path for that.
We can try again with BountySource.

Other communities are used to set up a sort of marketplace category. Not just for development purposes but also in order to set up a new NethServer installation and support it

Thanks for the reply. I was trying bountysource. But I didn’t figure out how to open an issue and set a bounty. Seems to be complicated or well, lack of intelligence on my part. If you could open the issue regarding my mail problem I could set a bounty.

If you are willing to research the problem, come up with a solution and test the code, I will sponsor the feature.
The main issue here is how to “map” user accounts to email addresses.
Describe how you would like to have it, please.


I would like to configure Nethserver NG 7.x to allows to send mails only if the sender ("From: ") is the same of the autenticated user or he/she have some allowed identities.

I tried with this article:

that it’s seems to do what I want, but I can’t make it work.

The identities may be differents from the user’s email domain.


my account in the server is saitobenkei@domain.tld and I want to be allow to send mails from my account only if in the "From: " field I put saitobenkei@domain.tld (my e-mail address) or some identities as pippo@domain.tld, saitobenkei@anotherdomain.tld, othermail@newdomain.tld (these are only identity that I allowed to use wit my account).

Some clue/help?


I managed to have a working implementation, but it is just for fun :slight_smile:
Creating a simple panel to configure this behavior would be complex.

Before proceed, you need to understand how it works, otherwise some users will not be able to send any mail. Take a look at:
So, let’s start.


1. Create a template-custom


mkdir -p /etc/e-smith/templates-custom/etc/postfix/

Content of /etc/e-smith/templates-custom/etc/postfix/

    push @submission_smtpd_options, 'smtpd_sender_restrictions=reject_authenticated_sender_login_mismatch';
    push @submission_smtpd_options, 'smtpd_sender_login_maps=hash:/etc/postfix/smtpd_sender_login_maps';


2. Create a map between users and allowed addresses

Content of /etc/postfix/smtpd_sender_login_maps: u1 u2

3. Apply the configuration


postmap /etc/postfix/smtpd_sender_login_maps

signal-event nethserver-mail-server-update


You can test it with curl.

This should be allowed:

curl -k -n --ssl-reqd --url "smtps://localhost:465" --mail-from --mail-rcpt --upload-file /dev/null -u u2:Nethesis,1234 -v

This should be denied:

curl -k -n --ssl-reqd --url "smtps://localhost:465" --mail-from --mail-rcpt --upload-file /dev/null -u u1:Nethesis,1234 -v


Also in this case Webtop 5 doesn’t care of the configuration and it sends mail with any identity is configured in the account.

It seems isn’t a 587 port “fault” because SMTP on Thunderbird, configured to use 587 port, works correctiy as expected.

I confirm that the port 587 honors the configuration, you can check it with:

curl -k -n --ssl-reqd --url "smtp://localhost:587" --mail-from --mail-rcpt --upload-file /dev/null -u u1:Nethesis,1234 -v

This is a completely different topic, each client can use its own configuration to set the “mail from” field (which could be completely different than “From:” header inside the message).

Webtop 5 seems to not honour configurations made here:

Thank you for pointing out this issue: it can be a validation point for the final implementation. i.e.:

“Can WT5 honor the sender address policy?”

How WT5 can implement it depends also on how NS implements it. We must see where this #feature request can lead us.

Just to make it clear, @saitobenkei do you want to force the envelope sender to be the same as the header one? See this link for an explanation

Please, also bear in mind that web applications installed on the mail server usually don’t use any authentication for sending mail, so no forced check cannot be done unless clients can be explicitly configured to act differently.

I would like that all applications (expecially those the are a standard in the distribution) work in a coherent manner…

If I need to set up that the account you send is the same as the one with which I authenticate myself, it must work with any software provided in the distribution.

(Same applies to blocking user-level mail/groupware access from untrusted networks).

1 Like

I’d rather say “it should work”: some software could not allow to implement this feature by now.

if there’s the rspamd module installed, the last command should be:

signal-event nethserver-mail2-server-update

1 Like

no nethserver-mail should have the same event nethserver-mail-server-save