2

I have a Debian server and have monit installed and running. I use the following settings for alert mails:

set mailserver localhost   # primary mailserver
set mail-format { from: monit@abc.test }
set alert admin@abc.test

I've started monit manually, and that resulted in local mails, to root@localhost. I want to receive mails via my personal mail address. I have postfix installed, and other applications (like Wordpress) can send out mails.

Why doesn't that work, and how can I get it working?

@Zoredache suggests to forward the mail to root@localhost to my own address. That sounds like a good solution. Now I'm wondering how I can get that working.

SPRBRN
  • 7,384
  • 14
  • 61
  • 90
  • Getting this setup right sounds good, but is there some reason why you couldn't just set an alias on the system to forward the mail from root@localhost to the address you prefer? – Zoredache Feb 10 '12 at 21:54
  • Thank you. I just updated the question with your suggestion. – SPRBRN Feb 10 '12 at 22:48

2 Answers2

1

To create an alias under most mail servers, and I believe postfix, just update the system alias file /etc/aliases. It almost certainly already exists, so you just have to go in and add or update a line.

root: me@example.com
suspectus
  • 4,735
  • 14
  • 25
  • 34
Zoredache
  • 19,828
  • 8
  • 50
  • 72
  • I update this line, restarted monit, which results in a new mail sent. I don't login as root, but as user rxt. The mail is sent to this user, not to the root user. This confuses me a bit, because I start monit as root. So the mail doesn't arrive at the moment. – SPRBRN Feb 10 '12 at 23:22
  • You would have to look at your existing aliases. Perhaps monit is sending to some other address that is already getting aliased to rxt? – Zoredache Feb 10 '12 at 23:28
  • The mailto address I used was on the same domain as the domain name for the machine. In the above example I used admin@abc.test, while abc.test pointed to this server, and admin was the username. The MX records for the mail for this domain points to a different server with a different provider, so I didn't consider that a problem. Now I've used a gmail address (root: abctest@gmail.com), and I reloaded the aliases with the command "newaliases". And voila! It works! :-) – SPRBRN Feb 11 '12 at 20:01
0

We need to set mailserver as localhost in /etc/monit/monitrc file

set mailserver localhost

Then restart monit service /etc/init.d/monit restart