Is possible to set external mail alias?

Hello to everyone!
I need to setup an office mail server to store locally a group of mail accounts for people working on that office. In this way I can centralize backup and synchronize using IMAP protocol all messages on all device of a user.

I’ll setup this server with domain companyname.local, because it will not manage completely all mail account of the company domain

Server will download (and remove) external mail using fetchmail from main external mail server.
Mail delivery will be done using a smarthost, the ISP’s SMTP server.

I have a problem only on mail sending: I’d like to add to local users with email username@companyname.local an alias (corrresponding to its real mail address on external mailserver)
In this way mailserver should deliver directly an email sent from its office without sending it through SMTP and then downloading it again using fetchmail.

I can’t setup Nethserver with domain name to make possible to send mail to mailboxes not managed by this server (external users of same company located in other offices)

In the past I was able to realize this mechanism adding a transport rule for postfix, but I don’t know how can I do that in Nethserver.

Have you a solution?
Thanks and regards

Hi @mdv

the scenario you describe is almost always source of post management troubles but, I must admit, a couple of times I have had to configure rule like that you mentioned.

I think that @filippo_carletti could help you (us).

1 Like

i think iy would be Usefull

Probably I found a solution this evening.
Reading some manuals of other mailserver solutions, I read an easy to do cheat. The domain need to be configured for the server as mycompany.local. Then each external user (that doesn’t download its mail from this server) need to be configured as a local user with a forward rule active for its external domain address (
In this way server should forward by external SMTP all e-mail destinated to external users out of this office.
The only (relative) problem is that I need to setup all accounts for external users, but this is not a great trouble!

Do you think is correct? Your opinion is greatly appreciated.


Hi Mauro,

yes it is a cheat but I think it solves your problem :wink:
If you cannot reorganize company’s domains and email users this is a ploy that does not complicate too much your internal mail server configuration.

Just an hint: in your internal mail server (I presume NethServer) configure SMTP relay to smtp server of ISP that host your domain just to avoid blacklist or SPAM issues.

Please let us know how it goes.

I agree… an old and wise man (FTR and @filippo_carletti, I’m talking of CB :slight_smile: ) told me once upon a time that a mta should never alter mail headers… if you need to send as user@domain.tld, you should config your client to do so…

OP should re-design his email/domain configuration

all IMHO

1 Like

Sorry for the confusion but I have again the same problem as beginning…
I try to explain again my problem because after many tests I cannot have the wanted results

Question probably answered by @filippo_carletti :
I have a server configured for the domain company.local that collects mails using fetchmail from external server associated to domain company.tld

in an existing installation that uses this scenario I had a Postfix server managed using MySQL database and configured for the domain “domain.local”.
I had a table called forwardings where I was able to put a record made of 2 fields like these:
Field1 [Source] user@domain.tld
Field2 [Destination] user@domain.local

Sending a mail from a client as sender@domain.tld to user@domain.tld the server recognized the recipient as an alias of user@domain.local and relayed the mail directly without sending it to the external mailserver

Is possibile to do the same using Nethserver?
Please help me!!!

Thanks and regards

you shoul do domain alias not user if u want sending mail localy
virtual_alias_domains = domain.tld

Nas… NS works on db, fragments, templates and events… this is the paradigm we all must follow…

editing conf file is useless…

moreover, I’m not a postfix guru, but I guess that doing such a thing EVERY mail sent to domain.tld will be treated as an internal mail… and this is not the desidered result.

finally… before giving suggestion you should think that tomorrow someone (without any kind of skill on NS) could read, do (without knowing what he’s doing) and break his server…

Thank you

1 Like

after restarting all mod files would be replaced from e-smith to default config !
Topic starter should write or paint how he would like to mail pass coz so many people so many minds!
or if it work for him he should correct /etc/e-smith/templates/etc/postfix files

and this is wrong, since he has to create files into /templates-custom/ tree

custom or none would work, it was checked on Shorewall when i setup Fail2ban!

if you edit files into /templates/ tree:

  • your editing will be lost the first time you update your server and those files are involved
  • your editing/customization will not included in backup

I repeat, NS follows some rules… you’d read the documentation (and believe me, I know quite well what I’m talking about ;-))

so he need only domain alias to send from internal ! external mail would come to MX record of a external domain!

only some mailbox are internal… treating domain.tld as local will not permit to send email to “external” mailboxes…

This is not the solution I want, because not all external server mailboxes user***@company.tld are retrieved from office server.
Only managed users*@company.local need to have it’s alias users*@company.tld
Server must deliver outside using smarthost all messages to recipients user*@company.tld not associated to local users

For example
Local users are user1@company.local and user2@company.local (they receive respectively external mail user1@company.tld and user2@company.tld)
External user is user3@company.tld. It doesn’t use office server, it download directly mail from ISP.

I want that if a mail is sent from user1@company.tld to user2@company.tld it’s relayed internally without use of smarthost.
But if user1@company.tld sends a mail to user3@company.tld server must send it to external server using smarthost. In this way user3 can download it from external server as usual.

If I make an alias for entire domain this is not possible, I’ll had an error saying that user3 is not an existing user.

Don’t make war!
Any solution?


Guess you can’t do this with NethServer, you can choose by domain which address should be forwarded to another mailserver and which managed locally. By domain not by user, so your goal is really tricky by webinterface
We’ll work in this for a multi-site nethserver configuration, by now there is no solution
Hope @davidep could be more accurate then me :wink:

1 Like

i think you should use virtual map for users who you want to move localy , other mail would come away throught smarthost!
virtual_alias_maps = hash:/etc/postfix/mail_alias

I’d like also a manual configuration via console. To make an alias for a user is needed only on user creation or deletion in my scenario.


First of all, I’M NOT A POSTFIX GURU, not tested

I searched a bit with google and found this:

then a took a look at


and then to


here’s my scenario…

ISP, mail server (MX record) on mail.domain.tld, ip AA.BB.CC.DD


domain: domain.tld, hostname=office1.domain.tld
you have to create here:
all the users and pseudonyms you have on ISP
a hostname
extmail.domain.tld pointing to AA.BB.CC.DD

at this point you’d have something like

userA@domain.tld       user1
userB@domain.tld       user2

and so on in /etc/postfix/virtual…

copy all the text including the “header”, like this:

# 20pseudonyms -- map to mailboxes:
userA@domain.tld       user1
userB@domain.tld       user2

create a new fragment:

mkdir -p /etc/e-smith/templates-custom/etc/postfix/virtual/20pseudonyms

edit it and paste the text

now edit the text in this way:

userA@domain.tld       user1
userB@domain.tld       user2
userC@domain.tld       extmail.domain.tld
userD@domain.tld       extmail.domain.tld


at this point you’ve to calla a signal-event to expand the template and restart the services…
sincerely I don’t know which is the right one, but I’m sure that @davidep or @alefattorini or @giacomo will tell us


domain: domain.tld, hostname=office2.domain.tld
you have to create here:
all the users and pseudonyms you have on ISP
a hostname
extmail.domain.tld pointing to AA.BB.CC.DD

repeat the same steps, altering only the users not local in site2, save, signal-event

theorically speaking, you’d be done…

the main issue is that if you add/delete an user/pseudonymn, you have to manually edit and modify the custom fragment on both sites.

I repeat: