Sending E-mail Notifications
To help you stay informed on the status of the stake pool that you operate, the Postfix mail server allows you to send e-mail notifications securely using Bash scripts.
To install and configure Postfix:
- Using a terminal window, type:sudo apt-get updatesudo apt-get install postfix mailutils libsasl2-modules
- When prompted to select the mail server configuration type, using the UP and DOWN arrow keys select the Internet With Smarthost option, then press the TAB key, and then press ENTER
Note

Selecting Internet with Smarthost simplifies configuring an e-mail account that you set up with a major service provider—such as Gmail, Microsoft Outlook or Yahoo Mail—to send notifications.
- When prompted for a mail name, press TAB to accept the default value, and then press ENTER
- When prompted for the SMTP relay host, type the default external host for Postfix to use when sending e-mail, then press TAB, and then press ENTER
Note

If you plan to configure an account that you set up with one of the following major service providers to send e-mail notifications using Postfix, then type the respective server name and port, for example:
- Gmail—
[smtp.gmail.com]:587 - Microsoft Outlook—
[smtp.office365.com]:587 - Yahoo Mail—
[smtp.mail.yahoo.com]:587
In Postfix, enclosing a hostname in square brackets (
[ ... ]) skips Domain Name System (DNS) MX record lookup and connects directly to the host using the A/AAAA record and specified port. - Gmail—
- When the installation completes, type the following commands to edit the
main.cfconfiguration file:cd /etc/postfixsudo nano ./main.cf - In the
main.cffile, add or edit the following lines:...# Set mail relay authorizationsmtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination...# Disable local mailbox deliverymydestination =...# Limit relaying to the local computermynetworks = 127.0.0.0/8 [::1]/128...# Bind only to the local loopback networkinet_interfaces = loopback-only...# Set Internet protocol versions that the Postfix server usesinet_protocols = all...# Enable SASL authenticationsmtp_sasl_auth_enable = yessmtp_sasl_password_maps = hash:/etc/postfix/sasl_passwdsmtp_sasl_security_options = noanonymoussmtp_sasl_tls_security_options = noanonymous# Enable TLS encryptionsmtp_use_tls = yessmtp_tls_security_level = encryptsmtp_tls_note_starttls_offer = yessmtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt - Save and close the
main.cffile. - If required by your e-mail service provider, create an app password for the e-mail account sending notifications.
- To set authentication credentials for the SMTP server, type:sudo nano /etc/postfix/sasl_passwd
- In the
sasl_passwdfile, add the following line where<SMTPRelayHost>is the SMTP relay host that you typed in step 4;<EmailAddress>is the e-mail address for the account sending e-mail notifications; and,<Password>is the password for acessing the account sending e-mail notifications or the app password that you generated in step 8<SMTPRelayHost> <EmailAddress>:<Password>Note

For example:
[smtp.gmail.com]:587 user@gmail.com:nxbnczhaocydwrsl - Save and close the
sasl_passwdfile, and then type:sudo chmod 600 /etc/postfix/sasl_passwdsudo postmap /etc/postfix/sasl_passwd - To prevent cron from e-mailing you standard output (STDOUT) and standard error (stderr) messages from cron jobs, type
crontab -eand then add the following line at the beginning of the file:MAILTO="" - Save and close the
crontabfile. - To restart the Postfix service, type:sudo systemctl restart postfix.service
To send an e-mail using Postfix:
- Using a terminal window, type the following command where
<MessageBody>is the information that you want the e-mail to include;<SubjectLine>is a descriptive summary of the e-mail; and,<RecipientEmailAddress>is the e-mail address receiving the e-mail:echo "<MessageBody>" | mail -s "<SubjectLine>" <RecipientEmailAddress>