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: [email protected] }
set alert [email protected]

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.

2
  • 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, 2012 at 21:54
  • Thank you. I just updated the question with your suggestion.
    – SPRBRN
    Feb 10, 2012 at 22:48

2 Answers 2

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: [email protected]
3
  • 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, 2012 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, 2012 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 [email protected], 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: [email protected]), and I reloaded the aliases with the command "newaliases". And voila! It works! :-)
    – SPRBRN
    Feb 11, 2012 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .