Email/Notification

From Bibliotheca Anonoma

http://wiki.hetzner.de/index.php/Softwareraid/en

This contacts you in case something goes wrong.

http://blog.ioflood.com/2015/04/21/setting-up-software-raid-mdadm-status-alert-emails-for-failed-drives-in-centos-ubuntu-and-debian/

http://www.tldp.org/HOWTO/Software-RAID-HOWTO-6.html#ss6.3

Set up SSL Certificate[edit]

You will need to set up a hostname (such as a subdomain, server.yourdomain.com) and an ssl certificate for that domain before you can send mail over SMTP.

https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-centos-7

Once you are done, link your certifiate to the postfix one:

sudo ln -s /etc/ssl/certs/ca-bundle.crt /etc/postfix/cacert.pem

Set up Postfix[edit]

You will need an SMTP server to send mail. This doesn't handle recieving mail. Setting it up is similar to setting up a SMTP mail client on your phone or with Thunderbird.

Install the postfix SMTP Server (usually already installed on RHEL):

sudo yum install postfix mailx

Setup with Amazon SES[edit]

Amazon SES does put you in a sandbox by default to reduce spam.

But you can verify the email addresses that are supposed to recieve it, which is great for just simple status reports from the server.

http://docs.aws.amazon.com/ses/latest/DeveloperGuide/postfix.html

Using SASL[edit]

You'll need to set up SASL support to use an SES account:

yum install cyrus-sasl-plain
service postfix restart

Now everything works fine for me:

[root@host postfix]# echo "SES test" | mail -s "SES test `date +%s`" -r "[email protected]" [email protected]

http://www.iredmail.org/forum/topic6582-iredmail-support-amazon-ec2-with-iredmail-and-amazon-ses.html

Setup With Gmail[edit]

Edit the postfix configuration file, and configure it with, for example, the Gmail SMTP servers:

sudo nano /etc/postfix/main.cf

relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes

Next, configure your email account, in this case Gmail:

sudo nano /etc/postfix/sasl_passwd

[smtp.gmail.com]:587    [email protected]:PASSWORD

Generate the hashed password db:

cd /etc/postfix
sudo postmap sasl_passwd

And now you're ready to send mail using Postfix. Here's an example command:

 echo "This is the message text." | mail -s "the message subject" [email protected]

Set up Systemd Notification[edit]