DEV Community

Cover image for How to set up email notifications on OpenIndiana
jdrch
jdrch

Posted on

1 1

How to set up email notifications on OpenIndiana

Do you want your OpenIndiana instance to let you know when something has gone wrong or if a cron job has failed? Here's how you do it.

First, tell the operating system to email you if anything goes into the maintenance, offline, or degraded states:

# svccfg setnotify -g to-maintenance,to-offline,to-degraded mailto:YourEmailAddress
Enter fullscreen mode Exit fullscreen mode

For failed cron jobs and the like, add the following lines to /etc/mail/aliases:

root:           YourEmailAddress
YourUsername:          YourEmailAddress
Enter fullscreen mode Exit fullscreen mode

Ensure there are no other conflicting root & YourUsername definitions (read: lines beginning with either of those.) If there are, either comment them out or resolve the conflicts using the commented instructions in the file.

Save /etc/mail/aliases when you're done editing, then run the following in the terminal:

# newaliases
Enter fullscreen mode Exit fullscreen mode

Now test your config by sending an email directly to YourEmailAddress¹, checking its inbox each time:

echo "This is the body of the email" | mail -s "This is the subject line" YourEmailAddress
Enter fullscreen mode Exit fullscreen mode

Then try sending an email to root:

echo "This is the body of the email" | mail -s "This is the subject line" root
Enter fullscreen mode Exit fullscreen mode

Finally, try sending an email to YourUsername:

echo "This is the body of the email" | mail -s "This is the subject line" YourUsername
Enter fullscreen mode Exit fullscreen mode

Those should all work.

¹ The emails I sent using this method did not have a subject line, so the -s might not work OpenIndiana. To be honest, I stole this line from Debian tutorial, so 🤷‍♂️. In any case, automated emails will have their own programmatically generated subject lines and bodies.

Top comments (0)