1

Topic: Local mail delivery on remote servers

Hi folks,

I'm looking for some help/advice on how to approach my current environment solution.
At the moment I have 4 servers, one is a VM hosting the mail server.
Mail on its own is working fine.

What I'm currently looking at is local mail delivery from all the other remote servers.
Some of the local users sending emails, like root has cronjob details ,...
They should go via my mail server.

Is it just a case of adding a mail account on the mail server, and add an entry on /etc/aliases on each of the boxes?

Another possible problem I'm looking at would be Webserver running on the remote hosts.
I think I can configure PHP for example to use SMTP.

But was wondering if there is a general solution to this, i.e. all mail going through my mail server.
Never had the problem before, as all services were running on the same machine, so sendmail was working as it should.
Now running each service on their own host, looks a little bit different.

Hope anyone could give me some advice on how to best approach this.

Thanks in advance,
Christian

2

Re: Local mail delivery on remote servers

You can try one of below:

- Make all other servers send mail via SMTP auth. just like a normal mail user, connect to mail server with SMTP port, authenticate, then send out email.

- Install postfix on all other servers, set "relayhost = [YOUR_MAIL_SERVER]", send mail just like before, (e.g. command line "mail -s 'subject' user@example.com < /etc/hosts'). On your mail server, append IP addresses of your other servers in postfix "mynetworks =".

3

Re: Local mail delivery on remote servers

Thanks,

the 2nd option sounds better to me.
With that I don't have to make any additional changes for other services, like webserver.

Was wondering if you think it would be a good idea to add this as a noption to the mail server install.
Like a client option which you can add on a remote server, after the server has been installed.
And add it to the the Admin GUI, to add the required IPs from the remote servers to the mail servers postfix config?

In general, I would like to see more options with the server setup, like how to add another server as backup mx, ...

4

Re: Local mail delivery on remote servers

I'm facing a minor problem with implementing the 2nd option.
The setup is like this:

Each system is holding a domain, some of them will host more then one domain in the future.
Servers have internal subdomains from hoster.

With the subdomain configured, I'm able to send out emails from CLI as root to my virtual mail users on the mail server.
But obviously, the 'From' field has the subdomain included.

So I played around with the postfix settings, and added the domain to '/etc/mailname' and 'myhostname' in /etc/postfix/main.cf

When I now try to send an email as root from CLI, I get the following errors on the mail server:

Mar  6 16:20:36 mail postfix/smtpd[28843]: connect from DOMAIN.TLD[IP]
Mar  6 16:20:36 mail postfix/smtpd[28843]: NOQUEUE: reject: RCPT from DOMAIN.TLD[IP]: 550 5.1.0 <root@DOMANI.TLD>: Sender address rejected: User unknown in virtual mailbox table; from=<root@DOMAIN.TLD> to=<derchris@DOMAIN.TLD> proto=ESMTP helo=<DOMAIN.TLD>
Mar  6 16:20:36 mail postfix/smtpd[28843]: disconnect from DOMAIN.TLD[IP]
Mar  6 16:20:36 mail postfix/smtpd[28843]: connect from DOMAIN.TLD[IP]
Mar  6 16:20:36 mail postfix/smtpd[28843]: NOQUEUE: reject: RCPT from DOMAIN.TLD[IP]: 550 5.1.1 <root@DOMANI.TLD>: Recipient address rejected: User unknown in virtual mailbox table; from=<> to=<root@DOMANI.TLD> proto=ESMTP helo=<DOMANI.TLD>
Mar  6 16:20:36 mail postfix/smtpd[28843]: disconnect from DOMAIN.TLD[IP]

I knwo there are 2 features in sendmail to work around this:

FEATURE(masquerade_envelope)dnl
FEATURE(genericstable)dnl

Is something similar available for postfix?
Or is there another way to get it to work.

5

Re: Local mail delivery on remote servers

I think first option will be more common and easier.

6

Re: Local mail delivery on remote servers

After creating the 'root' alias for the 'www' account I created for that domain, delivery from CLI to remote virtual mail users are working. So I guess I have to create an alias for every user the systems tries to send emails from.
Or would the local '/etc/aliases' take care of it?

7

Re: Local mail delivery on remote servers

derchris wrote:

Or would the local '/etc/aliases' take care of it?

It should be /etc/postfix/aliases by default in iRedMail.

Please make sure you have it enabled in postfix main.cf like below:

alias_maps = hash:/etc/postfix/aliases

8

Re: Local mail delivery on remote servers

ZhangHuangbin wrote:
derchris wrote:

Or would the local '/etc/aliases' take care of it?

It should be /etc/postfix/aliases by default in iRedMail.

Please make sure you have it enabled in postfix main.cf like below:

alias_maps = hash:/etc/postfix/aliases

I was not talking about the mail server.
I added a 'root: www@DOMAIN' to '/etc/aliases'
And also have other entried like www-data: root
So in theory if www-data tries to send an email, it will go to root, which will be forwarded to www@DOMAIN.

Or did I miss something here?

9

Re: Local mail delivery on remote servers

Sorry, '/etc/postfix/aliases' is on iRedMail server, and you're talking about /etc/aliases on your web server. I misunderstood. sad

10

Re: Local mail delivery on remote servers

I'm still looking into this and try to understand why this is like it is at the moment.

Local server:
/etc/mailname: DOMAIN.TLD
/etc/postfix/main.cf: myhostname = DOMAIN.TLD

Sending mails from user 'root' on CLI, no delivery, above error.

Adding 'root' alias, or create 'root' mailbox, delivery working.

Same is when I do the following changes:
Local server:
/etc/mailname: foobar.DOMAIN.TLD
/etc/postfix/main.cf: myhostname = foobar.DOMAIN.TLD

Mails will be delivered to the correct mail users.

So the main question is, why can't I send mails with DOMAIN.TLD, but have to create a mailbox or alias for each user I do.