H
Hype Drip

How to setup email alerts on linux using gmail or smtp

Author

Sebastian Wright

Published Mar 29, 2026

How to setup email alerts on linux using gmail or smtp
Linux machines may require administrative intervention in countless ways, but without manually logging into them how would you know about it? Here’s how to setup emails to get notified when your machines want some tender love and attention.

Of course, this technique is meant for real servers, but if you’ve got a Linux box sitting in your house acting as a home server, you can use it there as well. In fact, since many home ISPs block regular outbound email, you might find this technique a great way to ensure you still get administration emails, even from your home servers.

Overview

Configuring the Email sending ability for a machine immediately gives us the upshot that a lot of the system’s administration problems and critical alerts will be automatically sent to that system’s designated administrator. The most noteworthy example is that cron job execution errors fall into this category and therefore will notify the admin that there was a problem with scheduled jobs such as backups as soon as they happen including the standard error (stderr) output in the report. We will also be able to incorporate emailing from bash scripts.

Don’t worry—it usually doesn’t spam you with too much information and you can just de-configure it if it becomes to annoying.

On Debian based systems, other then a lot of very versatile emailing related programs there is also the ssmtp package, which is well suited if all you want to do is have an agent to send emails using another email server (MTA), without having to setup an entire postfix or sendmail configuration to do so.

Prerequisites and assumptions

Before we get started, you’ll want to make sure that all of these conditions are met:

  • You have an SMTP server that can receive the emails from your machines and send them to the recipient (i.e. your corporate exchange or Gmail).
  • You have the credentials for a user that is able to send Email on that server (i.e. a mailbox or a Gmail account).
  • This procedure has been used and tested on *Debian based systems (Lenny, Ubuntu & Mint), so if your not on one of those distributions your mileage may vary.
  • You will see me use VIM as the editor program, this is just because I’m used to it… you may use any other editor that you’d like.

*It is also used and tested on DD-WRT, but will only be covered in a future article (update: isn’t the future fun?) due to the setup and configuration variations necessary for such an embedded platform.

Setup

To install the ssmtp (Simple S.M.T.P) package, use the following command:

Then edit the configuration file:

Adjust and add as necessary the following parameters:

Change it from postmaster to the machines admin’s Email.

Your mail server in our case this is Gmail so we have to specify the port as 587, for regular SMTP servers this is usually not necessary.

Usually the name of the machine is automatically filled by the package setup, if the machine has a mailbox this should be fine, but if it doesn’t or the name is not the same as the mailbox adjust accordingly.

Enable TLS for secure session communication.

The username of the sending mailbox.

The password of the sending mailbox..

Sends the hostname instead of root[[email protected]].

In order to make the default (root) “from” field be the server name, edit the /etc/ssmtp/revaliases file:

And add into it the desired translation which in our Gmail examples case will be:

Incredibly this is all you have to do to enable the ability. From now on, the machine will Email you when something is up.

Confirming setup

Lets test that our ssmtp setup was correct by sending an Email:

echo “Test message from Linux server using ssmtp” | sudo ssmtp -vvv [email protected]

The “-vvv” turns on verbosity output so don’t get alarmed… this is just in case you encounter any problems, you will have some sort of output to Google for.
If all goes well, you should be getting the Email in a couple of seconds.

We will show scripted examples of this setup in future articles.

How to setup email alerts on linux using gmail or smtp

May your Emails be of the non-bouncing variety 🙂

Last updated on August 25, 2020 by Dan Nanni

Suppose you want to configure a Linux app to send out email messages from your server or desktop. The email messages can be part of email newsletters, status updates (e.g., Cachet), monitoring alerts (e.g., Monit), disk events (e.g., RAID mdadm ), and so on. While you can set up your own outgoing mail server to deliver messages, you can alternatively rely on a freely available public SMTP server as a maintenance-free option.

One of the most reliable free SMTP servers is from Google’s Gmail service. All you have to do to send email notifications within your app is to add Gmail’s SMTP server address and your credentials to the app, and you are good to go.

One catch with using Gmail’s SMTP server is that there are various restrictions in place, mainly to combat spammers and email marketers who often abuse the server. For example, you can send messages to no more than 100 addresses at once, and no more than 500 recipients per day. Also, if you don’t want to be flagged as a spammer, you cannot send a large number of undeliverable messages. When any of these limitations is reached, your Gmail account will temporarily be locked out for a day. In short, Gmail’s SMTP server is perfectly fine for your personal use, but not meant for commercial bulk emails.

With that being said, let me demonstrate how to use Gmail’s SMTP server in Linux environment.

Google Gmail SMTP Server Setting

If you want to send emails from your app using Gmail’s SMTP server, you need to adjust the security setting of the Gmail account to be used. Go to the Google account settings, and enable the option to allow less secure apps, which is off by default.

Then you will need to provide your app with the following details.

  • Outgoing mail server (SMTP server): smtp.gmail.com
  • Use authentication: yes
  • Use secure connection: yes
  • Username: your Gmail account ID (e.g., alice if your email is [email protected] )
  • Password: your Gmail password
  • Port: 587 (TLS) or 465 (SSL)

Exact configuration syntax may vary depending on apps. In the rest of this tutorial, I will show you several useful examples of using Gmail SMTP server in Linux.

Send Emails from the Command Line

As the first example, let’s try the most basic email functionality: send an email from the command line using Gmail SMTP server. For this, I am going to use a command-line email client called Mutt.

First, install Mutt as follows.

For Debian-based system:

For Red Hat based system:

Create a Mutt configuration file (

/.muttrc ) and specify in the file Gmail SMTP server information as follows. Replace with your own Gmail ID. Note that this configuration is for sending emails only (not receiving emails).

Now you are ready to send out an email using Mutt:

To attach a file in an email, use -a option:

How to setup email alerts on linux using gmail or smtp

Using Gmail SMTP server means that the emails appear as sent from your Gmail account. In other words, a recipient will see your Gmail address as the sender’s address. If you want to use your domain as the email sender, you need to use Gmail SMTP relay service instead.

Another note is that if you are concerned about placing your SMTP password in the plain-text .muttrc file, you can encrypt the password using GnuPG.

Send Email Notification When a Server is Rebooted

If you are running a virtual private server (VPS) for some critical website, one recommendation is to monitor VPS reboot activities. As a more practical example, let’s consider how to set up email notifications for every reboot event on your VPS. Here I assume you are using systemd on your VPS, and show you how to create a custom systemd boot-time service for automatic email notifications.

First create the following script reboot_notify.sh which takes care of email notifications.

In the script, I use -F option to specify the location of system-wide Mutt configuration file. So don’t forget to create /etc/muttrc file and populate Gmail SMTP information as described earlier.

Now let’s create a custom systemd service as follows.

Once the service file is created, enable and start the service.

From now on, you will be receiving a notification email every time the VPS gets rebooted.

How to setup email alerts on linux using gmail or smtp

Send Email Notification from Server Usage Monitoring

As a final example, let me present a real-world application called Monit, which is a pretty useful server monitoring application. It comes with comprehensive VPS monitoring capabilities (e.g., CPU, memory, processes, file system), as well as email notification functions.

If you want to receive email notifications for any event on your VPS (e.g., server overload) generated by Monit, you can add the following SMTP information to Monit configuration file.

Here is the example email notification sent by Monit for excessive CPU load.

How to setup email alerts on linux using gmail or smtp

Conclusion

As you can imagine, there will be so many different ways to take advantage of free SMTP servers like Gmail. But once again, remember that the free SMTP server is not meant for commercial usage, but only for your own personal project. Also, for security reasons, it is a probably good idea to create a throw-away Gmail address just for email notifications, instead of using your own personal Gmail account. If you are using Gmail SMTP server inside any app, feel free to share your use case.

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal (Credit Card) or Bitcoin ( 1M161JGAkz3oaHNvTiPFjNYkeABox8rb4g ).

Before we get started, you’ll want to make sure that all of these conditions are met:

· You have an SMTP server that can receive the emails from your machines and send them to the recipient (i.e. your corporate Gmail).

· You have the credentials for a user that is able to send Email on that server (i.e. a mailbox or a Gmail account).

Setup

To install the ssmtp (Simple S.M.T.P) package, use the following command:

sudo aptitude install ssmtp

Then edit the configuration file:

Adjust and add as necessary the following parameters:

Change it from postmaster to the machines admin’s Email.

Your mail server in our case this is Gmail so we have to specify the port as 587, for regular SMTP servers this is usually not necessary.

Usually the name of the machine is automatically filled by the package setup, if the machine has a mailbox this should be fine, but if it doesn’t or the name is not the same as the mailbox adjust accordingly.

Enable TLS for secure session communication.

The username of the sending mailbox

The password of the sending mailbox

Sends the hostname instead of root[[email protected]].

In order to make the default (root) “from” field be the server name, edit the /etc/ssmtp/revaliases file:

And add into it the desired translation which in our Gmail examples case will be:

Incredibly this is all you have to do to enable the ability. From now on, the machine will Email you when something is up.

Confirming setup

Lets test that our ssmtp setup was correct by sending an Email:

# echo “Test message from Linux server using ssmtp” | sudo ssmtp -vvv [email protected]

The “-vvv” turns on verbosity output so don’t get alarmed… this is just in case you encounter any problems, you will have some sort of output to Google for.

If all goes well, you should be getting the Email in a couple of seconds.

How to setup email alerts on linux using gmail or smtp
Linux machines may require administrative intervention in countless ways, but without manually logging into them how would you know about it? Here’s how to setup emails to get notified when your machines want some tender love and attention.

Of course, this technique is meant for real servers, but if you’ve got a Linux box sitting in your house acting as a home server, you can use it there as well. In fact, since many home ISPs block regular outbound email, you might find this technique a great way to ensure you still get administration emails, even from your home servers.

How to setup email alerts on linux using gmail or smtp

Overview

Configuring the Email sending ability for a machine immediately gives us the upshot that a lot of the system’s administration problems and critical alerts will be automatically sent to that system’s designated administrator. The most noteworthy example is that cron job execution errors fall into this category and therefore will notify the admin that there was a problem with scheduled jobs such as backups as soon as they happen including the standard error (stderr) output in the report. We will also be able to incorporate emailing from bash scripts.

Don’t worry—it usually doesn’t spam you with too much information and you can just de-configure it if it becomes to annoying.

On Debian based systems, other then a lot of very versatile emailing related programs there is also the ssmtp package, which is well suited if all you want to do is have an agent to send emails using another email server (MTA), without having to setup an entire postfix or sendmail configuration to do so.

Prerequisites and assumptions

Before we get started, you’ll want to make sure that all of these conditions are met:

  • You have an SMTP server that can receive the emails from your machines and send them to the recipient (i.e. your corporate exchange or Gmail).
  • You have the credentials for a user that is able to send Email on that server (i.e. a mailbox or a Gmail account).
  • This procedure has been used and tested on *Debian based systems (Lenny, Ubuntu & Mint), so if your not on one of those distributions your mileage may vary.
  • You will see me use VIM as the editor program, this is just because I’m used to it… you may use any other editor that you’d like.

*It is also used and tested on DD-WRT, but will only be covered in a future article (update: isn’t the future fun?) due to the setup and configuration variations necessary for such an embedded platform.

Setup

To install the ssmtp (Simple S.M.T.P) package, use the following command:

Then edit the configuration file:

Adjust and add as necessary the following parameters:

Change it from postmaster to the machines admin’s Email.

Your mail server in our case this is Gmail so we have to specify the port as 587, for regular SMTP servers this is usually not necessary.

Usually the name of the machine is automatically filled by the package setup, if the machine has a mailbox this should be fine, but if it doesn’t or the name is not the same as the mailbox adjust accordingly.

Enable TLS for secure session communication.

The username of the sending mailbox.

The password of the sending mailbox..

Sends the hostname instead of root[[email protected]].

In order to make the default (root) “from” field be the server name, edit the /etc/ssmtp/revaliases file:

And add into it the desired translation which in our Gmail examples case will be:

Incredibly this is all you have to do to enable the ability. From now on, the machine will Email you when something is up.

Confirming setup

Lets test that our ssmtp setup was correct by sending an Email:

echo “Test message from Linux server using ssmtp” | sudo ssmtp -vvv [email protected]

The “-vvv” turns on verbosity output so don’t get alarmed… this is just in case you encounter any problems, you will have some sort of output to Google for.
If all goes well, you should be getting the Email in a couple of seconds.

We will show scripted examples of this setup in future articles.

How to setup email alerts on linux using gmail or smtp

May your Emails be of the non-bouncing variety 🙂

More stories

Week in Geek: Developers Battle Against Android Crapware Edition

This week we learned how to choose a partition scheme for a Linux PC, create an index table like a pro with Microsoft Word, do a complete makeover of PowerPoint Slides with Pptplex, use a Wii remote as a gyroscopic mouse, know the difference between desktop and professional printers, and more.

The How-To Geek Guide to Learning Photoshop, Part 6: Digital Art

For artistic readers, Photoshop offers digital painting options few other painting or photomanipulation programs can equal. Whether you want to draw for a living, or simply want to paint for fun, learning the painterly side of Photoshop is very rewarding.

Desktop Fun: Thanksgiving Day Wallpaper Collection [Bonus Edition]

Are you ready for Thanksgiving and all that tasty food? While you wait for the holiday to arrive we have a larger than normal set of wallpapers to help set the mood on your desktop.

Screenshot Tour: XBMC Media Center 10 Has Add-ons, Skins, and More

XBMC is free and open source software that is released for Windows, OS X, Linux, AppleTV, and as a live image that can be run directly from a CD/USB drive or installed to turn an extra computer into a true HTPCВ appliance. XBMC gives you theВ functionalityВ of many media streamers currently on the

Friday Fun: Turkey Fling

The weekend is almost here, so why not have some fun while you wait to finish out the work day? This week your mission is to help a turkey do the best he can to escape being a part of the Thanksgiving Day feast!

How to Maximize Battery Life on Your iPad, iPhone, or iPod Touch

Whatever you do, don’t leave your iPhone or iPod sitting in a hot car—heat kills batteries faster than any other factor, and your device that used to keep a charge for hours will eventually barely hold a charge, and you’ll have to pay Apple to get it replaced. The same thing holds true for any

Google Apps Customers Now Have Access to Full Set of Google Services

Have you been patiently waiting to access the full range of Google services in your Google Apps account? Your wait is finally over! Today Google announced the availability of the same services available to regular Google acco.

Add Holiday Style Effects to Your Photos with Glitterboo

Do you have photos that you want to make festive looking for the upcoming holidays? Glitterboo can add special effects to your images and make them something special to look at.

Fun Social Networks School Class Photo [Image]

deviantART member darkywarky has created a fun image with popular internet social networks portrayed as students in a class photo.

How to Use FileMenu to Manage Your Files More Efficiently

Organizing files can be very time consuming, and moving files between folders often requires a lot of mouse clicks between one file directories to another. Here’s how to use FileMenu to do these tasks more efficiently.

GOAL: Get a text file on my file server into my gmail inbox.

The file server is running Ubuntu Server 8.04 I currently SSH into it from time to time and to check logs, SMART stats for hard drives, and such. I’m looking into setting up a scheduled script that runs some commands and sends me the output via email.

The only issue I’m having is with actually getting the email sent. I have no experience with email config under linux and all guides pointing to sendmail seem to assume lots of things on behalf of myself and my current config. The servers are set up for file sharing with samba and NOT as mail, web, or dns servers. I don’t want to run a mail server or route anything from the server or receive any mail on (or with) the server, unless any of that helps me accomplish the goal. The file server is on our normal network and has internet access.

I own several website domains (and have a hosting package). I’ve been able to set up apps like thunderbird to send mail using one of the accounts from my website by filling in smtp.mydotcom.com for the outgoing server to use and changing ports etc to match the information from my website’s cpanel config page. Is there a way to do something similar so I can send an email from my file server to my external email?

EDIT: Here are the steps I took after reading Dennis Williamson’s answer below. I was up and running in only a few minutes!

I created a new email account on my website (called “alerts”) and edited /etc/esmtprc like this:

(These values were provided by the cpanel admin page)

Then I created a file called “eheader” with the default top of email:

So, in order to fire off the mail the following command can be used:

So it’s easy to vary which files are sent for the daily/weekly/etc jobs.

Sep 28, 2020 · 6 min read

How to setup email alerts on linux using gmail or smtp

There will be times when we want to send out some data, stats or resource alerts to our email from Linux host.

In this tutorial I am going to show how to setup emails to get notified when your machines want some tender love and attention.

There will be prompts asking General type of mail configuration. Select Internet Site:

How to setup email alerts on linux using gmail or smtp

Enter the fully qualified name of your domain.
here its kmaster-rj.example.com.

How to setup email alerts on linux using gmail or smtp

After the installation completion, ensure that the myhostname parameter is configured with your server’s FQDN:

When Two-Factor Authentication (2FA) is enabled, Gmail is preconfigured to refuse connections from applications like Postfix that don’t provide the second step of authentication.

While this is an important security measure that is designed to restrict unauthorized users from accessing your account, it hinders sending mail through some SMTP clients as you’re doing here. Follow these steps to configure Gmail to create a Postfix-specific password:

  • Log in to your email, then click the following link: Manage your account access and security settings. Scroll down to “Password & sign-in method” and click 2-Step Verification. You may be asked for your password and a verification code before continuing. Ensure that 2-Step Verification is enabled.
  • Click the following link to Generate an App password for Postfix:

How to setup email alerts on linux using gmail or smtp

  • Click Select app and choose Other (custom name) from the dropdown. Enter “Postfix” and click Generate.
  • The newly generated password will appear. Write it down or save it somewhere secure that you’ll be able to find easily in the next steps, then click Done:

How to setup email alerts on linux using gmail or smtp

  • You can verify the presence of password we generated just now

How to setup email alerts on linux using gmail or smtp

Usernames and passwords are stored in sasl_passwd in the /etc/postfix/sasl/ directory.

Now you will have to add your email login credentials to this file and to Postfix.

  • Create /etc/postfix/sasl/sasl_passwd file if not exist by default and add your gmail ID and password we

Note: The SMTP server smtp.gmail.com supports message submission over port 587 (StartTLS) and port 465 (SSL). Whichever protocol you choose, be sure the port number is the same in /etc/postfix/sasl/sasl_passwd and /etc/postfix/main.cf files.

  • create the hash file for Postfix using the postmap command

If the above command is executed successfully, then you should have a new file named sasl_passwd.db in the /etc/postfix/.

Since sasl_passwd consists of username and password in plain text, so it is recommended to change the file permission to root. This is to esnure that only the root user is able to read and edit the credentials in this file.

Modify the main.cf file and set the relayhost entry to external SMTP server address as below.

Note: if you have specified port no in sasl_passwd i.e. 587 as in the above example, then we need to specify in the same in the main.cf file also.

Save your changes and close the file.

Lets test whether our SMTP server can send emails to an external gmail account using sendmail command. Postfix logs can help as well.

Change body and subject line accordingly and in place of email address use valid email id.

Lets send some interesting CPU usage data to our email address.
It will trigger an email when your system reaches 4% CPU utilization.

Its very less threshhold btw 🙂 just to show you the usage I’ve taken this. You can do a stress test to increase the load average.

Note: Please change the email id and CPU utilization threshold value (which is 4 here) as per your requirement.

Verify on your email inbox (don’t forget to check in spam folder if not found in primary mailbox)

How to setup email alerts on linux using gmail or smtp

Note: You can configure the SMTP with different providers as well for e.g mandrill , sendgrid etc. You just need to update the sasl password. Everything else will remain same.

How to fix postfix/smtp Network unreachable error:

When trying to send email to a gmail account through postfix you can see an error like this in the postfix logs /var/log/maillog :

Solution for IPv4

If you want to use IPv4 instead, then you should edit the Postfix configuration file and change inet_protocols = all to inet_protocols = ipv4 and restart or reload Postfix:

and flush the Postfix queue or just wait and mail will start to send.:

Mail queue operations

To see mail queue, enter:
# mailq

To remove all mail from the queue, enter:
# postsuper -d ALL

To remove all mails in the deferred queue, enter:
# postsuper -d ALL deferred

Sending Mail

1. Send Full Mail using the following command:

OR you can also send mail to multiple recipients:

it asks for cc: and mail body

Press Ctrl+D for send mail

2. Mail in a Single Line

Hope you like the tutorial. Please let me know your feedback in the response section.

  • Page History
  • Login to edit

Here’s how to setup sending emails through command line. A common application could be to send an alert message through user created script.

  • Ubuntu Server/Desktop
  • Gmail account

Update Ubuntu Repository

Install the ssmtp package

Edit the configuration file. The lines without the # are the ones we are interested in.

Adjust and add as necessary to match the following parameters

Create aliases for local usernames (optional)

edit the /etc/ssmtp/revaliases file

And add into it the desired translation which in our Gmail examples case will be

From now on, the machine will Email when requested through command line or script.

Lets test that our ssmtp setup was correct by sending an Email

The “-vvv” turns on verbosity output.

Unfortunately a few thing can go wrong.

Check username and password again

  • Check google is not blocking your new device
  • EmailAlerts (последним исправлял пользователь evilnick 2017-05-11 22:03:33)

    To run in production, Mattermost requires SMTP email to be enabled for email notifications and password reset for systems using email-based authentication.

    How to Enable Email 

    To enable email, configure an SMTP email service as follows:

    Set up an SMTP email sending service (if you don’t yet have an SMTP service with credentials)

    Any SMTP email service can be used, you just need the following information: Server Name , Port , SMTP Username , and SMTP Password .

    If you don’t have an SMTP service you can set one up with:

    1. Go to Amazon SES console then

    SMTP Settings > Create My SMTP Credentials

    Copy the Server Name , Port , SMTP Username , and

    SMTP Password for Step 2 below.

    From the Domains menu set up and verify a new domain,

    then enable Generate DKIM Settings for the domain.

    1. We recommend you set up Sender Policy Framework (SPF) and/or Domain Keys Identified Mail (DKIM) for your email domain.

    Choose a sender address like [email protected] and

    select Send a Test Email to verify setup is working correctly.

    By local sendmail can be used by using Server Name 127.0.0.1 with Port 25

    Or by using one of the services listed below in the Sample SMTP Settings

    Configure SMTP settings

    Go to Product menu > System Console.

    Alternatively, if a team doesn’t yet exist navigate to your serverURL and select Go To System Console.

    Go to the Authentication > Email tab and configure the following:

    Allow Sign Up With Email: true

    Go to the Notifications > Email tab and configure the following:

    Send Email Notifications: true

    Notification Display Name: Display name on email account sending notifications

    Notification Email Address: Email address displayed on email account used to send notifications

    SMTP Username: SMTP Username from Step 1

    SMTP Password: SMTP Password from Step 1

    SMTP Server: SMTP Server from Step 1

    SMTP Port: SMTP Port from Step 1

    Connection Security: TLS (Recommended)

    Then select Save

    Then select Test Connection

    If the test failed please look in OTHER > Logs for any errors that look like [ERROR] /api/v4/email/test .

    (Optional) Go to the Security > Sign Up tab and configure the following:

    Enable Email Invitations: true

    Sample SMTP Settings 

    Amazon SES 

    Set SMTP Username to [YOUR_SMTP_USERNAME]

    Set SMTP Password to [YOUR_SMTP_PASSWORD]

    Set SMTP Server to email-smtp.us-east-1.amazonaws.com

    Set SMTP Port to 465

    Set Connection Security to TLS

    Postfix 

    Make sure Postfix is installed on the machine where Mattermost is installed

    Set SMTP Username to (empty)

    Set SMTP Password to (empty)

    Set SMTP Server to localhost

    Set SMTP Port to 25

    Set Connection Security to (empty)

    Gmail 

    Set SMTP Username to [email protected]

    Set SMTP Password to your_password

    Set SMTP Server to smtp.gmail.com

    Set SMTP Port to 587

    Set Connection Security to STARTTLS

    Additional configuration is required in Google to allow SMTP email to relay through their servers. See SMTP relay: Route outgoing non-Gmail messages through Google for the required steps.

    Hotmail 

    Set SMTP Username to [email protected]

    Set SMTP Password to your_password

    Set SMTP Server to smtp-mail.outlook.com

    Set SMTP Port to 587

    Set Connection Security to STARTTLS

    Office365/Outlook 

    Set SMTP Username to [email protected]

    Set SMTP Password to your_password

    Set SMTP Server Name to smtp.office365.com

    Set SMTP Port to 587

    Set Connection Security to STARTTLS

    Troubleshooting SMTP 

    TLS/STARTTLS Requirements 

    If you fill in SMTP Username and SMTP Password then you must set Connection Security to TLS or to STARTTLS

    Troubleshooting using Logs 

    If you have issues with your SMTP install, from your Mattermost team site go to System Console > Logs to look for error messages related to your setup. You can do a search for the error code to narrow down the issue. Sometimes ISPs require nuanced setups for SMTP and error codes can hint at how to make the proper adjustments.

    For example, if System Console > Logs has an error code reading:

    Search for 554 5.7.1 error and Client host rejected: Access denied .

    Checking your SMTP server is reachable 

    Attempt to Telnet to the email service to make sure the server is reachable. For additional information, visit If you’re using an earlier version than Exchange Server 2019, select your version from the left-hand navigation menu.

    You must run the following commands from the same machine or virtual instance where mattermost/bin/mattermost is located.

    Telnet to the email server with telnet mail.example.com 25 . If the command works you should see something like:

    Then type something like HELO mail server domain> . If the command works you should see something like:

    As we’re not installing telnet by default on the official docker images you either need to use ping on those or install telnet yourself either directly or by modifying the Dockerfile.

    For further assistance, review the Troubleshooting forum for previously reported errors, or join the Mattermost user community for troubleshooting help. To submit an improvement or correction to this page, select Edit in the top-right corner of the page.

    • English
    • PortuguГЄs
    • Р СѓСЃСЃРєРёР№
    • дё­ж–‡
    • FranГ§ais
    • TГјrkГ§e
    • EspaГ±ol

    Sidebar

    Overview

    To configure e-mail as the delivery channel for messages, you need to configure e-mail as the media type and assign specific addresses to users.

    Configuration

    To configure e-mail as the media type:

    • Go to Administration в†’ Media types
    • Click on Create media type (or click on E-mail in the list of pre-defined media types).

    The Media type tab contains general media type attributes:

    How to setup email alerts on linux using gmail or smtp

    All mandatory input fields are marked with a red asterisk.

    ParameterDescription
    NameName of the media type.
    TypeSelect Email as the type.
    SMTP serverSet an SMTP server to handle outgoing messages.
    SMTP server portSet the SMTP server port to handle outgoing messages.
    This option is supported starting with Zabbix 3.0.
    SMTP heloSet a correct SMTP helo value, normally a domain name.
    SMTP emailThe address entered here will be used as the From address for the messages sent.
    Adding a sender display name (like “Zabbix-HQ” in Zabbix-HQ in the screenshot above) with the actual e-mail address is supported since Zabbix 2.2 version.
    There are some restrictions on display names in Zabbix emails in comparison to what is allowed by RFC 5322, as illustrated by examples:
    Valid examples:
    [email protected] (only email address, no need to use angle brackets)
    Zabbix HQ (display name and email address in angle brackets)
    ∑Ω-monitoring (UTF-8 characters in display name)
    Invalid examples:
    Zabbix HQ [email protected] (display name present but no angle brackets around email address)
    “Zabbix\@\ “ (although valid by RFC 5322, quoted pairs and comments are not supported in Zabbix emails)
    Connection securitySelect the level of connection security:
    None – do not use the CURLOPT_USE_SSL option
    STARTTLS – use the CURLOPT_USE_SSL option with CURLUSESSL_ALL value
    SSL/TLS – use of CURLOPT_USE_SSL is optional
    This option is supported starting with Zabbix 3.0.
    SSL verify peerMark the checkbox to verify the SSL certificate of the SMTP server.
    The value of “SSLCALocation” server configuration directive should be put into CURLOPT_CAPATH for certificate validation.
    This sets cURL option CURLOPT_SSL_VERIFYPEER.
    This option is supported starting with Zabbix 3.0.
    SSL verify hostMark the checkbox to verify that the Common Name field or the Subject Alternate Name field of the SMTP server certificate matches.
    This sets cURL option CURLOPT_SSL_VERIFYHOST.
    This option is supported starting with Zabbix 3.0.
    AuthenticationSelect the level of authentication:
    None – no cURL options are set
    (since 3.4.2) Username and password – implies “AUTH=*” leaving the choice of authentication mechanism to cURL
    (until 3.4.2) Normal password – CURLOPT_LOGIN_OPTIONS is set to “AUTH=PLAIN”
    This option is supported starting with Zabbix 3.0.
    UsernameUser name to use in authentication.
    This sets the value of CURLOPT_USERNAME.
    This option is supported starting with Zabbix 3.0.
    PasswordPassword to use in authentication.
    This sets the value of CURLOPT_PASSWORD.
    This option is supported starting with Zabbix 3.0.
    EnabledMark the checkbox to enable the media type.

    To make SMTP authentication options available, Zabbix server should be compiled with the –with-libcurl compilation option with cURL 7.20.0 or higher.

    Options

    The Options tab in the e-mail media type configuration contains alert processing settings. The same set of options are configurable for other media types, too.

    All media types are processed in parallel. The maximum number of concurrent sessions is configurable per media type, but the total number of alerter processes on server can only be limited by the StartAlerters parameter. Alerts generated by one trigger are processed sequentially.

    How to setup email alerts on linux using gmail or smtp

    ParameterDescription
    Concurrent sessionsSelect the number of parallel alerter sessions for the media type:
    One – one session
    Unlimited – unlimited number of sessions
    Custom – select a custom number of sessions
    Unlimited/high values mean more parallel sessions and increased capacity for sending notifications. Unlimited/high values should be used in large environments where lots of notifications may need to be sent simultaneously.
    If more notifications need to be sent than there are concurrent sessions, the remaining notifications will be queued; they will not be lost.
    AttemptsNumber of attempts for trying to send a notification. Up to 10 attempts can be specified; default value is ‘3’. If ‘1’ is specified Zabbix will send the notification only once and will not retry if the sending fails.
    Attempt intervalFrequency of trying to resend a notification in case the sending failed, in seconds (0-60). If ‘0’ is specified, Zabbix will retry immediately.
    Time suffixes are supported, e.g. 5s, 1m.

    User media

    To assign a specific address to the user:

    • Go to Administration в†’ Users
    • Open the user properties form
    • In Media tab, click on Add

    Notifications work in the form of email. The backend software used here is postfix [1] configured as a MTA in satellite mode. The options allow to configure to send mail via SMTP servers using the standard port or use SSL/TLS. The web interface allows the configuration of two recipient addresses. Both are assigned to the root user.

    ConfigurationВ¶

    The central MTA configuration is stored in /etc/postfix/main.cf

    openmediavault creates the /etc/postfix/recipient_canonical to define the root (admin) and normal users mail addresses when added via the web interface. Example:

    When a scheduled task is defined to run as a certain user the output generated from that task, will be sent to that user defined mail.

    The last line is the catch all address. For example a scheduled task set to be run as user with no mail defined in their profile will get the output generated sent to the catch all address ( [email protected] ). The same will happen with any other mail action intended for an undefined user (not in that list).

    Mails can be sent from terminal also with mail command. mail receives from stdin.

    Mail will be delivered to [email protected] as it is defined in canonical_recipients. The delivery address can be explicit also:

    Mail will delivered to [email protected] because user john does not have an email address defined in canonical_recipients, so it goes to the catch all address.

    openmediavault stores the configuration values in the database (including the password). Before posting information for support please sanitize the values.

    EventsВ¶

    The server will send notifications for this events:

    • Log in from browser (If cookies are allowed, then it just sends once).
    • Use of sudo by a user not in allowed group.
    • Summary of locked users by pam_tally2 [2]. This happens when a user or admin attempts fails to log in for more than three times.
    • MD RAID events: degraded, reshape, etc. [D]
    • Monit software: php-fpm, nginx, netatalk, rrdcached, collectd and omv-engined. [D]
    • Monit filesystem: usage and mount points. [D]
    • Monit system: CPU, Load and memory usage. [D]
    • Scheduled tasks. [D]
    • Rsync jobs. [D]
    • Cron-apt: Summary of upgrade packages available. [D]
    • SMART: Report of attribute changes. [D]

    Options marked with [D] can be disabled selectively. The rest only when the whole notification backend is disabled.

    GmailВ¶

    Gmail can be used in notifications. If you have 2FA enabled for the account, then is necessary to create an app password. Please use the following settings:

    Aliases are allowed. This is good for filtering later in gmail. [email protected] can be [email protected] or [email protected] .

    Gmail requires “access for less secure applications” to be enabled, in order for openmediavault to send notifications using smtp.gmail.com . Enable access for less secure applications.

    Third Party NotificationsВ¶

    Whenever a mail is dispatched by the MTA, postfix will execute a run-parts of this directory /usr/share/openmediavault/notification/sink.d , passing the following environmental variables:

    Also the following positional arguments are passed:

    Most modern non mail notifications systems have a documented API, where you can send text using curl payloads with a secret TOKEN . So most common case would be to use OMV_NOTIFICATION_MESSAGE_FILE variable only in your script.

    Your script’s filename must adhere to the following standards:

    Must belong to one or more of the following namespaces:

    • The LANANA-assigned namespace (^[a-z0-9]+$)
    • The LSB hierarchical and reserved namespaces (^_?([ a-z0-9_ .]+-)+[a-z0-9]+$)
    • The Debian cron script namespace (^[ a-zA-Z0-9_ -]+$)

    Start with a number like this: pushnotification

    • Do not add an extension to your script in the run-parts directory, otherwise it will get excluded.
    • Make sure the script file is executable. In this case also make sure the script is not a symlink to a mounted filesystem with noexec flag.

    In ActiveXperts, you can send out e-mail alerts through virtually any SMTP server.
    To send out e-mail alerts through Google’s Gmail SMTP server, make sure you:

    • Step 1: Allow 3rd party application in Google, to enabled ActiveXperts to use the Gmail SMTP services.
      This is described in our online document: Allow ActiveXperts to use Google’s Gmail mail services through SMTP.
    • Step 2: Configure Gmail SMTP configuration in ActiveXperts Network Monitor.

    Step 1: Allow 3rd party application in Google, to enabled ActiveXperts to use the Gmail SMTP services.

    If you have not enabled Gmail for 3rd party applications yet, you should follow the instructions in our document: Allow ActiveXperts to use Google’s Gmail mail services through SMTP.
    If you don’t allow 3rd party applications, you’ll end up with ActiveXperts error 37411: “Authorization failed; Make sure that 3rd party applications are allowed.”. See also this screenshot.

    Step 2: Configure Gmail SMTP configuration in ActiveXperts Network Monitor

    In the ‘Notification Settings’ property page, configure the following settings:

    • In the SMTP host field, type: smtp.gmail.com
    • In the SMTP port field, type: 465
    • In the Connection Security selection box, select SSL/TLS
    • Enable the Server requires Authentication checkbox, and enter a login with the ‘@gmail.com’ suffix (e.g. [email protected])
    • In the Sender’s e-mail field, type the Gmail account exactly as specified in the Authentication field above (e.g. [email protected])

    How to setup email alerts on linux using gmail or smtp

    Press the ‘Test SMTP Server’ button to test the e-mail settings. If you get error #37411, then please read Step 1.

    • View account
    • View requests
    • Log out

    Knowledge base

    Products

    Jira Software

    Project and issue tracking

    Jira Service Management

    Service management and customer support

    Jira Core

    Manage any business project

    Confluence

    Bitbucket

    Git code management

    Resources

    Documentation

    Usage and admin help

    Community

    Answers, support, and inspiration

    Suggestions and bugs

    Feature suggestions and bug reports

    Marketplace

    Billing and licensing

    Frequently asked questions

    • Log out
    • Log in to account
    • List watched pages
    • Contact support
    • Evaluator resources
    • Training & Certification
    • Cloud Migration Center
    • GDPR guides
    • Enterprise services
    • Atlassian partners
    • Developers
    • User groups
    • Automation for Jira
    • Atlassian.com

    Viewport

    Confluence

    Versions
    • 8.1
    • 8.0
    • 7.2
    • 7.1
    • 7.0
    • 6.10
    • 6.9
    • 6.8
    • 6.7
    • 6.6
    • 6.5
    • See all

    Configuring notifications for a plan and its jobs

    • Configuring Bamboo to send SMTP Email
    • Configuring Bamboo to use Instant Messaging
    • Modifying notification templates

    On this page

    Related content

    • No related content found

    Still need help?

    The Atlassian Community is here for you.

    Bamboo can send email notifications about its build results. There are two steps to setting this up:

    1. Configure Bamboo to send SMTP email (see below).
    2. Configure a plan to send SMTP email notifications about build results (see Configuring notifications for a plan and its jobs).

    On this page:

    Configuring Bamboo to send SMTP email

    To configure Bamboo to send SMTP email:

      From the top navigation bar select >Communication >Mail server.

    Edit the mail server settings as necessary:

    Name
    A display name for the email address e.g. SMTP Server.

    From address
    The email address from which Bamboo notifications will be sent.

    Subject prefix
    The text (if any) which will be added to the start of the email subject line. For example [Bamboo] will result in emails with subjects like:

    • [Bamboo] TEST build 1,001 has FAILED (77 tests failed, no failures were new) : Change made by jsmith
    • [Bamboo] TEST build 1,002 was SUCCESSFUL (with 77 tests) : Change made by jsmith

    Email settings
    Select either SMTP or JNDI . See the Notes about JNDI below.

    SMTP server
    The address of the email server that Bamboo will use to send notifications e.g. mail.myserver.com.

    Username
    The login name of the account that Bamboo will use to login to the SMTP server.

    JNDI Location
    Depends on your application server, and on the location of the mail resource within the JNDI tree you specify. E.g. java:comp/env/mail/BambooMailServer.

  • Enter a test email address in the Test recipient address box.
  • Select Test, and verify that a test email is received.
  • Select Save.
  • Configuring email notifications for Gmail

    Gmail.com uses TLS (SSL). A JNDI connector needs to be configured. Unfortunately Bamboo does not yet support JNDI with TLS.

    To enable Gmail as your mail server:

    After you’ve created your Grafana dashboard (as described in the Creating Metrics Dashboards in Grafana topic), you can add metric-based rules designed to alert you if your API’s performance hits a certain threshold.

    For example, if you want to receive a notification when your API sends or receives a certain amount of data, or when there’s a large lag time between requests and responses, you can configure Grafana to assess that metric and send you an email in the event your API hits the defined threshold.

    How to setup email alerts on linux using gmail or smtp

    To do so, you must:

    Create a Grafana alert channel to specify where your alerts should be sent.

    Add an alert rule to the dashboard element you want to use to track an API metric.

    Creating an Alert ChannelВ¶

    To create an alert channel, you must first configure some email related settings in your Grafana custom.ini file:

    Navigate to your Grafana conf folder (by going to the folder in which you placed your Grafana installation and following the path grafana-version.number.windows-x64\grafana-version.number\conf ).

    Use CTRL + F to find the smtp section of custom.ini.

      Configure the smtp section of your custom.ini file as follows:

      Uncomment the enabled line (by removing the semicolon at the beginning of the line) and enter enabled = true.

      Uncomment the host line and enter host = smtp.youremailprovider:portnumber. For example, if your email provider is Gmail, enter host = smtp.gmail.com:587.

      Uncomment the user line and enter user = youremail @ youremailprovider . com. For example, if your email is test @ gmail . com, enter user = test @ gmail . com.

      Uncomment the password line and enter password = youremailpassword. For example, if the password for the email account you entered in step c is 12345, enter password = 12345.

      Uncomment the skip_verify line and enter skip_verify = true.

      Uncomment the from_address line and enter from_address = youremail @ youremailprovider . com.

      Uncomment the from_name line and enter from_name = Grafana.

      Then, you’ll use these email settings to create a notification channel within Grafana itself:

      From the Grafana sidebar, select Alerting > Notification channels.

      From the Alerting screen, select New Channel .

      Configure your channel as follows:

      In the Name field, enter a name such as Grafana Dashboard Alerts.

      In the type field, enter Email.

      In the Email addresses field, enter the email to which you want to send alerts.

      Select the Save button to save this alert channel. Then, select the Send Test button to send yourself a test alert. You should receive confirmation that the test was sent successfully.

      Now, let’s plug your alert channel into an actual alerting rule, created within one of your dashboard elements, to configure an email alert.

      Creating Alert RulesВ¶

      Navigate back to your metric dashboard (by selecting Dashboards > Manage from the Grafana sidebar and then selecting your dashboard).

      Select the title of the element for which you’d like to configure an email alert. In this example, we’re going to use the Request and Response Data Total element we created for our example dashboard. Then, select Edit.

      Go to the Alert tab. Select Create Alert .

      Fill out the following fields in the Alert Config section:

      In the Name field, enter a name for this alert. We’re going to create an alert that evaluates the amount of request data our API has received, so we’ll name our alert Requests Higher Than 20K.

      In the Evaluate every field, enter the time period at which you want Grafana to re-evaluate this rule and send you an alert if its conditions are met.

      In the Conditions section, enter the conditions to be met for your rule to evaluate to True and your alert to be sent. For our example, we’ll enter “WHEN count () of query (A, 5m, now) IS ABOVE 20000” to create a rule that sends us an alert when our API has received more than 20,000 bytes of data. For a more in-depth examination of the rules you can create, refer to Grafana’s own rules documentation.

      Select Notifications from the Alert form’s left-hand sidebar. Then, fill out the following fields:

      In the Send to field, select the alert channel you created above.

      In the Message field, enter the message you want to include in your alert. For example, for our alert, we could enter a message like “Your API is receiving an abnormally large amount of request data.”

      And that’s it; you’ve configured your email alert. At this point, we highly recommend testing the workflow that should trigger your rule and fire an alert, to confirm you receive an alert as expected. If you don’t, you might have to reconfigure your rule.

      Also, we highly recommend you review Grafana’s own documentation on alert rules and the alerting engine, to learn more about what sorts of rules and workflows you can configure using Grafana.

      © 2019 Mertech Data Systems | All rights reserved. developed by Thriftly

      To send email notifications, you need to:

      Configure an SMTP server

      Before sending notifications via email, the system needs to know about the SMTP Simple Mail Transfer Protocol (SMTP) is the mechanism by which an email client program sends emails to an outgoing mail server (SMTP server) for delivery to the intended email address. server that is sending the emails. The SMTP server can be internal or external to your organization, however, it must allow forwarding of emails to your users. The SMTP server is typically the same server that users set in their email application to send email.

      PaperCut NG/MF comes with a number of popular SMTP services preconfigured to simplify the configuration process. If you use these, you only need to provide the login credentials of the SMTP server.

      How to setup email alerts on linux using gmail or smtp

      Follow the instructions based on the service you want to configure:

      Anti-virus software running on the PaperCut NG/MF server can block/disallow SMTP connections because it attempts to block spam sent by viruses and trojans. Ensure that any anti-virus software is configured to allow PaperCut NG/MF to make SMTP connections (for example, add an exception or disable the SMTP blocking).

      When anti-virus is blocking email delivery and PaperCut NG/MF performs email notification tests, it logs errors, such as: Mail server connection failed. Software caused connection abort. . These errors are displayed in the application log The application log retains a complete history of system events, such as security errors (such as incorrect password attempts), user logins, backup times and scheduled tasks, any system errors or warning. or on-screen .

      If there are other SMTP connection problems, check that your firewall allows SMTP connections, and that your SMTP server is configured to accept connections from the PaperCut NG/MF server.

      Particularly when using external email services like Gmail, click the Reject untrusted certificates checkbox. This prevents man-in-the-middle attacks by blocking the connection if the mail server presents a certificate that hasn’t been signed by a trusted certificate authority.

      Do not tick the checkbox if you run your own mail server with a self-signed certificate.

      Configure email addresses

      To be able to send notification messages to users via email, define the email address(es) for the users in the User Details page ( Users > User List , click username). However, if all email addresses match the pattern [username]@yourdomain.com , you can define the email address globally using the global email suffix. Here’s an example:

      An email notification needs to be sent to user brian .

      No email address has been defined in Brian’s user details, but a global email suffix of @myschool.com is defined in the Notifications page, Email Options area.

      To generate Brian’s email address, PaperCut NG/MF combines the username ( brian ) and suffix ( @myschool.com ) to form the email address [email protected] .

      To define the global email suffix:

      Click Options > Notifications .

      The Notifications page is displayed.

      In the Email Options area, click the Use email suffix to build user email addresses checkbox.

      How to setup email alerts on linux using gmail or smtp

      Enter the Email address suffix .

      To confirm that the email suffix is working as expected:

      Click the Users tab.

      The User List page is displayed.

      The User Details page is displayed.

      Select the Use global email suffix checkbox.

      The email field contains the address constructed from the username and suffix.

      Comments

      Share your findings and experience with other PaperCut users. Feel free to add comments and suggestions about this Knowledge Base article. Please don’t use this for support requests.

      We are here to help

      As a company full of techies we know how important a well supported product is.

    • Join the conversation:
    • Twitter
    • LinkedIn
    • Facebook
    • Spiceworks
    • YouTube

    Sending A Test Alert E-mail

    Select the Administration > Alerts tab and click the Send Test Alert link.

    Configuring the List Of Alert Recipient Email Addresses

    1. Select the Administration > Alerts tab and click Edit to the right of Recipient(s).
    2. Select Scope > Alert Publisher .
    3. Select Category > Main .
    4. Locate the Alerts: Mail Message Recipients property or search for it by typing its name in the Search box.
    5. Configure the Alerts: Mail Message Recipients property.
    6. Click the Save Changes button at the top of the page to save your settings.

    To apply this configuration property to other role groups as needed, edit the value for the appropriate role group. See Modifying Configuration Properties Using Cloudera Manager.

  • Restart the Alert Publisher role.
  • Configuring Alert Email Properties

    1. Display the Cloudera Management Service status page.
    2. Click the Configuration tab.
    3. Select Scope > Alert Publisher .
    4. Select Category > Main to see the list of properties. To receive email alerts, you must set (or verify) the following settings:
      • Enable email alerts
      • Email protocol to use.
      • Your mail server hostname and port.
      • The username and password of the email user that will be logged into the mail server as the “sender” of the alert emails.
      • A comma-separated list of email addresses that will be the recipients of alert emails.
      • The format of the email alert message. Select json if you need the message to be parsed by a script or program.

    To apply this configuration property to other role groups as needed, edit the value for the appropriate role group. See Modifying Configuration Properties Using Cloudera Manager.

  • Click the Save Changes button at the top of the page to save your settings.
  • Restart the Alert Publisher role.
  • In this tutorial, you will learn how to configure Grafana Email alerting. Grafana alerting allows you to attach rules to your dashboard panels. When you save the dashboard, Grafana extracts the alert rules into a separate alert rule storage and schedules them for evaluation. When an alert changes state, it sends out notifications through various channels including Email, Slack, Google Hangout Chat or several other integrations.

    Alerting is only available in Grafana v4.0 and above and is only supported on graph panels, at least as at now.

    Getting Started with Grafana? Check the link below;

    Configure Grafana Email Alerting

    There are several notification channels that you can configure your Grafana to sent alerts through. However, this tutorial focusses on how to configure Grafana Email alerting.

    To demonstrate Grafana Email alerting, we have created dashboards for monitoring system metrics using Prometheus and Grafana. See the dashboard below for visualizing the load average for a system.

    To easily demonstrate Grafana email alerting, we will setup Grafana to sent alerts when the load for the last 1, 5, 15 mins is 3.00,2.00,1.00.

    Configure Grafana SMTP settings

    Before Grafana can be able to sent email alerts, you need to configure how alerts will be relayed.

    In this demo, we will configure Grafana to Gmail relay to sent out emails. You can use any of your preferred mail servers.

    Hence, open the Grafana configuration file and navigate to smtp section.

    Check the values for the highlighted lines and replace them accordingly.

    Pay attention to the line, # If the password contains # or ; you have to wrap it with triple quotes. Ex “””#password;”””.

    Save and exit the file.

    Restart Grafana service;

    Note: If you are using Gmail relay, ensure that you turn on less secure apps to sent mails.

    Add Grafana Notification Channel

    Click Alerting icon (bell like icon) on the Grafana side bar and then click Notification channel. This should open up the Alerts and Notifications page;

    Click Add Channel to create a new Email notification channel

    1. Set the name of the channel
    2. Choose the channel notification method, Email is used in this case.
    3. Enter addresses of the recipients. Multiple addresses are separated using semi-colon.
    4. Select your notification settings;

    Once you have configured your channel settings, click Test to verify email deliverability.

    If all is fine, you should get Test notification sent.

    Also, you should receive Test notification email on your recipient inbox.

    If not, check Grafana logs;

    Save the Channel, when done testing.

    Click on the title of the graph panel that you want to configure alerts for and click Edit. For example in our case, we have a graph for CPU load average.

    When the panel is opened for editing, click on the Alert tab.

    Next, click Create Alert to setup your alerting;

    • Set the rule name and frequency for evaluation of your threshold before an alert is sent out (we set it to evaluate a threshold for 1 min every 1 mins for easy demo).
    • Set the rule conditions based on the number of queries your graph panel have. So we have three queries and hence three conditions of each Query.

    When you set the conditions, an icon shown in the screenshot below is set on the graph panel;

    • No data and error handling settings
    • Choose the Notification channel created earlier by clicking Send to.
    • Set the notification message body. You can create your custom message as you see fit;

    Save the dashboard when done setting the alert rule and conditions and notifications.

    Test the alerting by clicking on Test rule.

    Now your graph panel shows like as below with all the values of the last 1,5,15 mins load average within the range. With green line showing the threshold is fine.

    Now, we need to simulate the CPU usage by running the command below;

    run the command below like four times on the terminal;

    Watch the CPU hike using htop/top or w commands as you view your grafana graph.

    Once you see the red line, that is when the alert if fired.

    The mail alert notification;

    And there you go.

    You have successfully configure Grafana email alerting.

    NOTE: The Approach A sections referred to below do not apply to Bitnami native installers. Users of Bitnami native installers should refer only to the Approach B sections.

    Email settings can be configured in the Redmine configuration.yml configuration file.

    NOTE: Depending on your installation type, the Redmine configuration.yml configuration file can be found in the following locations:

    Approach A (Bitnami installations using system packages): installdir/redmine/config/configuration.yml

    Approach B (Self-contained Bitnami installations): installdir/apps/redmine/htdocs/config/configuration.yml

    The file includes sample configuration settings for most common scenarios, including Gmail. To use Gmail as the SMTP server, find and uncomment the Gmail settings such that you end up with the result below. Remember to update the user_name and password variables with the correct credentials for the Gmail account you plan to use.

    After making this change, log in to the Redmine administration panel and navigate to the “Administration -> Settings -> Notifications” page. Update the sender address on this page to match the address defined in the Redmine configuration.yml configuration file edited previously.

    Once the configuration settings have been modified, restart the services following these instructions for Linux, Windows and macOS.

    To change the link that appears in the email, navigate to the “Administration -> Settings -> General -> Host name and path” section and enter your domain name and port.

    Troubleshooting email configuration issues

    In case you receive an error message containing “530 5.7.0 Must issue a STARTTLS command first …”, make sure you have the enable_starttls_auto property set after the password line. For example:

    In Redmine 2.0 or greater, if you see an error similar to “An error occurred while sending mail (SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol)”, remove the tls: true option from the configuration.yml file. Then, restart the services as described in the previous section.

    If using an SMTP server that does not require authentication, you may need to add the openssl_verify_mode: ‘none’ option to the configuration.yml file.

    NOTE: If you are using Gmail as the outbound email server, your application’s attempts to send outgoing emails may be blocked by Gmail if it considers the authentication attempts to be suspicious. When this happens, you will receive a Gmail security alert at the corresponding Gmail address. To proceed, you will need to manually confirm the validity of the authentication attempt before Gmail will permit the application to send outbound emails. For more information on this and other Gmail issues related to outbound email from your application, refer to our Gmail SMTP troubleshooting page.

    The author voluntarily contributed this tutorial as a part of Pepipost Write to Contribute program.

    Introduction

    Notifications are getting more important these days to stay updated among various online activities. Moreover, these notifications can be emails, SMS or push. This tutorial is going to demonstrate you the simplest way of sending notifications, over one of the most popular channels that is email. You are going to learn the process of sending emails from the terminal or a shell script from a Linux operating system, using some of the popular CLI tools.

    This tutorial is going to help you in sending critical server-level emails like Cron reports, script logs, customer registrations, receipt, bank statement over email. There are many ways to send emails from the server, but let’s explore the tool that’s easy to install and easy to code.

    With simple libraries and little configurations, you can have a CLI tool in your Linux OS that you can use to send mails from the terminal.

    Prerequisites

    • Linux operating system
    • SMTP Configurations (SMTP server details and authentication credentials)
    • Your favourite editor (Optional)
    • Configure Gmail SMTP/ready with any other custom SMTP server details. In this tutorial, you are going to use Gmail SMTP to send emails, so make sure that;
      undefinedundefined

    Google SMTP server configurations would look something like this:

    • SMTP Server/Hostname: smtp.gmail.com
    • SMTP Username: [Your Gmail Address]
    • SMTP password: [Your Gmail Password]
    • SMTP Port: 587
    • TLS/SSL: Required

    Its time to now open terminal

    There are various tools and libraries which you can install to send emails from the terminal. Few of the popular libraries are:

    • sSMTP
    • Mailx

    In this tutorial, you’re going to learn the steps on how to install and use sSMTP to send mails from your Linux command line. Click here, in case you want to learn how to install and use Mailx to send mails from your Linux command line.

    How to install sSMTP to send mails from your Linux command line (CLI)

    Step 1

    Use the below command to install ssmtp:

    Optional:
    CentOS users can use the below command to install ssmtp:

    In CentOS, you may see an error during installation as “package ssmtp is not available”, in such a case below command, is going to be helpful to fix the issue:

    Step 2

    Once ssmtp installed successfully, you need to make the below global configurations which required for sending mail.

    Open the following file in your favourite editor:

    Edit the above file with the below details:

    The above configuration is going to be used to send email using your Gmail SMTP. In case you want to use some other third-party SMTP, then mention the hostname of the same. e.g. if you want to use Pepipost SMTP, then instead of smtp.gmail.com, you need to mention smtp.pepipost.com in the mailhub parameter. mailhub is used for SMTP server address which consists of two part host:port

    Now you are all set to sending mails from the command line (CLI).

    Step 3

    There are multiple ways to use ssmtp command to send emails.

    Case 1: Send Mail Directly From The Command Line

    For this, copy-paste the below command, and you’re ready to send email from your command line:

    -vvv is the verbosity to see the logs while sending the mail

    Case 2: Send Mail From A Shell Script

    You can use the same ssmtp to send mail from a shell script too. For that, open your preferred editor and create a shell script file with name saymail.shand copy-paste the below code:

    Make sure you have set the right permission access to your script file. If not, here is the command to set the permission:

    Now, the code is ready to be executed. Just run the shell script using the below command:

    Hope now you’re able to send mails using the shell script too.

    Below are few errors/exceptions which you may encounter while sending the mail using ssmtp:

    Error 1

    In case while sending the email, if might get the below error as output:
    ssmtp: Authorization failed (535 5.7.8 u65smyez14952a76922r5pfui.104 – gsmtp)

    Solution: In such a case, try doing following as solution:

    1. Enable “Allow less secure app” in your google accounts settings, as explained in the above prerequisites section.
    2. The provided login credentials can be invalid. Make sure you have the correct credentials.

    Once the issue is fixed, re-run the shell script and the success output will be something like this;

    Conclusion

    Hope the steps explained above were useful and you were able to successfully send mail using linux command line (CLI). Feel free to contribute, in case you encountered some issue which is not listed as a part of this tutorials.
    Use below comments section to ask/share any feedback.

    Integrate your Linux Command line with Pepipost SMTP

    No SMTP connection issues. Send your first 30,000 emails for free.

    Once you’ve got your server up and running the last thing you want to be doing is logging onto it every 5 minutes to check everything is ok. That said, some people actually enjoy doing this and if you’re one of those people then you can skip this page completely. For the rest of you, read on!

    If you’ve been following this guide from the start you’ll know I’ve configured my server to send me an email if either the CPU or any of the hard drives exceed my pre-determined temperatures. I also get emails when any of my Torrents have downloaded. I also get emails to tell me about the state of my SnapRAID Array. Infact you can get email alerts on pretty much anything you desire!

    Whilst you can install and configure a fully featured email system you really don’t need to do so if all you want to do is send emails and not receive them too. I use ssmtp which is a simple Mail Transfer Agent (MTA). It’s not rocket science to install ssmtp, it’s one simple command, although configuring it can be a bit more challenging. So, how do you install it?

    How to install ssmtp

    Before we do anything else we should bring the Ubuntu Repository up to date. So, from a Putty Session or, if you’ve got a screen and keyboard attached to your server, then you can use the command line itself to type the following:

    sudo apt-get update

    You’ll be prompted for a password. This is the password you created when you installed Ubuntu. Ubuntu tends to prompt for a password each time you issue a “sudo” command.

    Next we can install the ssmtp package:

    sudo apt-get install ssmtp

    How to configure ssmtp

    Now we’ve installed the package we need to configure it. I’m using my gmail account to handle all my emails but you can obviously use your favourite email address. Obviously you should alter the following to text suit your own setup:

    Firstly, we’ll configure the config file. I like to use vim which is a powerful but simple text editor (issue: sudo apt-get install vim if you don’t have it installed already). So, let’s edit the config file

    sudo vim /etc/ssmtp/ssmtp.conf

    This will open the config file for editing. Then press the [Insert] key once to switch into Insert Mode and edit the file as follows. I mask out the original lines using a # but you can simply edit them instead:

    Once you’ve finished editing the file press the [Esc] key once and type :wq to save and quit out of the file. If you make a mistake editing the file then issue :q! instead of :wq to abort your changes.

    Adding reverse aliases

    A reverse alias changes the “From” address. This means you can make the email appear as if it’s from a different email address. I personally haven’t done this but if it’s something you’d like to do then edit the revaliases file as follows:

    sudo vim /etc/ssmtp/revaliases

    Then add a new line similar to this:

    How to test you have configured ssmtp properly

    Once you’ve configurd sSMTP it’s time to try and send an email. The simplest way to do this is to run sSMTP in a terminal with a recipient email address. So:

    sSMTP will then wait for you to type your message, which needs to be formatted like this:

    Note the blank like after the subject field. Everything you type from the Hello World! onwards is the body of the email. Once you have finished composing your email hit Ctrl-D. After a few seconds sSMTP will send the message.

    Obviously you don’t want to be doing stuff from the Command Line each time you want to send an email so it’s better to write a little text file containing the email contents. Here is such a text file for use in the script which monitors CPU Temperatures:

    If you look at the script itself you can see it’s being called on the following line:

    Once you have configured sSMTP it becomes the default “email client” and so you’ll start receiving relevant output from your Cron jobs too.

    The SMTP platform allows you to deliver notifications from Home Assistant to an e-mail recipient.

    To enable notification by e-mail in your installation, add the following to your configuration.yaml file:

    Check your e-mail provider configuration or help pages to get the correct SMTP settings.

    Configuration Variables

    Setting the optional parameter name allows multiple notifiers to be created. The notifier will bind to the service notify.NOTIFIER_NAME .

    E-mail address of the sender.

    Default E-mail address of the recipient of the notification. This can be a recipient address or a list of addresses for multiple recipients.
    This is where you want to send your E-mail notifications by default (when not specifying target in the service call). Any E-mail address(es) specified in the service call’s target field will override this recipient content.

    SMTP server which is used to send the notifications.

    The port that the SMTP server is using.

    The timeout in seconds that the SMTP server is using.

    Username for the SMTP account.

    Password for the SMTP server that belongs to the given username. Make sure to wrap it in double quotes; e.g., “MY_PASSWORD” .

    Set mode for encryption, starttls , tls or none .

    Sets a custom ‘sender name’ in the emails headers (From: Custom name [email protected] ).

    Enables Debug, e.g., true or false .

    Usage

    To use the SMTP notification, refer to it in an automation or script like in this example:

    The optional target field is used to specify recipient(s) for this specific service call. When target field is not used, this message will be sent to default recipient(s), in this example, [email protected] and [email protected] .

    The optional images field adds in-line image attachments to the email. This sends a text/HTML multi-part message instead of the plain text default.

    The optional html field makes a custom text/HTML multi-part message, allowing total freedom for sending rich html emails. In them, if you need to attach images, you can pass both arguments ( html and images ), the attachments will be joined with the basename of the images, so they can be included in the html page with src=”cid:image_name.ext” .

    To learn more about how to use notifications in your automations, please see the getting started with automation page.

    Specific E-Mail Provider Configuration

    Check below some configurations examples for specific e-mail providers. If you are in doubt about the SMTP settings required, check your e-mail provider configuration or help pages for more information about its specific SMTP configuration.

    Google Mail

    A sample configuration entry for Google Mail.

    Keep in mind that Google has some extra layers of protection that need special attention. By default, the usage by external applications is limited so you will need to visit the less secure apps page and enable it to be able to send e-mails. Be aware that Google will periodically turn it off if it is not used (no e-mail is sent).

    To avoid having your e-mail notifications broken due to the less secure app’s behavior, it is recommended that you enable 2-step verification on your Google account, and use an application-specific password in your notification configuration.

    Latest releases¶

    Resources¶

    • Email Configuration
      • Configuration Directives
        • authentication
        • delivery_method
          • Asynchronous delivery_methods
      • Example configuration.yml Configurations
        • Simple Login Authentication (default settings)
        • GMail, Google Apps
        • Office 365, Exchange Online
        • No Authentication
        • Using sendmail command
      • Troubleshooting
        • Error: “hostname was not match with the server certificate”
        • Error: “Mail failure – no recipient addresses”
        • Error: “Timeout:Error” due to SSL SMTP server connection
      • More information

    Configuration Directives¶

    This page is a work in progress, the following configuration directives are only a partial list. Please consult Action Mailer Configuration
    for detailed information.

    authentication¶

    The type of authentication method expected by your service provider.

    Valid settings:

    • nil (or omit the key) for no authentication
    • :plain
    • :login
    • :cram_md5

    (note: if you set this to nil or omit it, you must not include the user_name and password settings)

    delivery_method¶

    The mail transport method to be used.

    Valid settings (= :smtp

  • : sendmail
  • :async_smtp
  • :async_sendmail
  • Valid settings (>= Redmine v4.x; cf. #30068):

    • :smtp
    • : sendmail

    Asynchronous delivery_methods¶

    The :async_smtp and :async_sendmail use asynchronous sends, which means Redmine does not wait for the email to be sent to display the next page. See Asynchronous Email Delivery for more details. Some SMTP servers have delay period before processing takes place as an anti-spam feature, during which time synchronous method will block Redmine (10 seconds could be a default value, see also #11376 for more information).

    With this delivery method, smtp configuration is specified using async_smtp_settings keyword instead of smtp_settings keyword:

    Please note: Since Redmine 4.0 asynchronous email sending is removed in favour of Rails ActiveJob module which sends emails asynchronously.See for more details.

    Example configuration.yml Configurations¶

    Simple Login Authentication (default settings)¶

    GMail, Google Apps¶

    If you want to use GMail/Google Apps and other TLS-requiring SMTP servers, you’ll have to add some TLS-related settings:

    When sending from G Suite (formerly Google Apps), it’s good to use SMTP relay which has much larger sending limits.
    More information and detailed guide how to enable SMTP relay is here:
    When configuring SMTP relay service use something like this:

    • Name: Redmine
    • 1. Allowed senders:
      • Only registered Apps users in my domains – in case You have created dedicated G Suite user for Redmine
    • 2. Authentication
      • [x] Only accept mail from the specified IP addresses – IP address of your Redmine server
      • [x] Require SMTP Authentication
    • 3. Encryption
      • [x] Require TLS encryption

    And config can be really simple:

    Office 365, Exchange Online¶

    Here is an example for Office 365 users (Exchange online). The sender must have an account, or if you want to send from a shared mailbox, the account below must have authorization to “Send As” the sender which is defined in Redmine email notifications settings.

    No Authentication¶

    Example for an SMTP service provider with no authentication.

    Using sendmail command¶

    Example for a unix system that uses the /usr/sbin/sendmail command.

    Troubleshooting¶

    Error: “hostname was not match with the server certificate”¶

    If you get this error, there’s probably a problem verifying the SSL certificate of your smtp relay. As a temporary fix, you can set this option in the appropriate “email_delivery” section:

    If you have to enable starttls and just want to bypass the certificate verification, you can add following option in the appropriate “email_delivery” section:

    Error: “Mail failure – no recipient addresses”¶

    When this error happens, the notification is not delivered to the destination address. Instead, you will probably receive a rejection message on your sender address, where you can see the header of the message sent, containing “From:” fields but not containing any “To:” fields.

    This error is common on Debian boxes, due to the way exim4 is configured by default, which is “-i -t” . This configuration tells exim4 that the destination address is inside the header of the message. Instead, we need to configure exim4 so that the destination address will be retrieved from the command line.

    The solution consists on editing your config/configuration.yml and making sure you define arguments containing the string “-i” , as shown below:

    The example above employs :sendmail method, which employs sendmail_settings . In case you are using :smtp or :async_smtp methods, try smtp_settings instead.

    Update: This article is part of WordPress-Nginx tutorials series.

    If you want to use a Gmail account as a free SMTP server on your Ubuntu-Linux server, you will find this article useful. This guide is tested with Ubuntu 12.04. If you face any issue, feel free to use comments-section below.

    Relaying Postfix mails via smtp.gmail.com:

    First, install all necessary packages:

    If you do not have postfix installed before, postfix configuration wizard will ask you some questions. Just select your server as Internet Site and for FQDN use something like mail.example.com

    Then open your postfix config file:

    and following lines to it:

    You might have noticed that we haven’t specified our Gmail username and password in above lines. They will go into a different file. Open/Create

    And add following line:

    If you want to use your Google App’s domain, please replace @gmail.com with your @domain.com

    Fix permission and update postfix config to use sasl_passwd file:

    Next, validate certificates to avoid running into error. Just run following command:

    Note: If you run into issues with above command, try changing certificate name to thawte_Primary_Root_CA.pem in above command. Thanks Alexander Bakker for the note.

    Finally, reload postfix config for changes to take effect:

    Testing

    Check if mails are sent via Gmail SMTP server

    If you have configured everything correctly, following command should generate a test mail from your server to your mailbox.

    To further verify, if mail sent from above command is actually sent via Gmail’s SMTP server, you can log into Gmail account [email protected] with PASSWORD and check “Sent Mail” folder in that Gmail account. By default, Gmail always keeps a copy of mail being sent through its web-interface as well as SMTP server. This logging is one strong reason that we often use Gmail when mail delivery is critical.

    Once configured, all emails from your server will be sent via Gmail. This method will be useful if you have many sites on your server and want them all to send emails via Gmail’s SMTP server.

    Alternatively, you can use a plugin like WP Mail SMTP so that mails from your particular WordPress site will be sent using Gmail’s SMTP server.

    Please note that Gmail’s SMTP server has a limit of 500 emails per day. So use wisely! 🙂

    Troubleshooting

    Error: “SASL authentication failed; server smtp.gmail.com”

    You need to unlock the captcha by visiting this page

    You can run test again after unlocking captcha.

    sSMTP is a program which delivers email from a local computer to a configured mailhost (mailhub). It is not a mail server (like feature-rich mail server sendmail) and does not receive mail, expand aliases or manage a queue. One of its primary uses is for forwarding automated email (like system alerts) off your machine and to an external email address.

    Contents

    • 1 Installation
    • 2 Forward to a Gmail mail server
    • 3 Security
    • 4 Sending email
      • 4.1 Attachments
      • 4.2 Mail to Local Users
    • 5 See also

    Installation

    Forward to a Gmail mail server

    To configure sSMTP, you will have to edit its configuration file ( /etc/ssmtp/ssmtp.conf ) and enter your account settings.

    • If your Gmail account is secured with two-factor authentication, you need to generate a unique App Password to use in ssmtp.conf . You can do so on your App Passwords page. Use you Gmail username (not the App Name) in the AuthUser line and use the generated 16-character password in the AuthPass line, spaces in the password can be omitted.
    • If you do not use two-factor authentication, you need to allow access to unsecure apps. You can do so on your Less Secure Apps page.

    Create aliases for local usernames (optional)

    To test whether the Gmail server will properly forward your email:

    Change the ‘From’ text by editing /etc/passwd to receive mail from ‘root at myhost’ instead of just ‘root’.

    Which changes /etc/passwd to:

    Security

    Because your email password is stored as cleartext in /etc/ssmtp/ssmtp.conf , it is important that this file is secure. By default, the entire /etc/ssmtp directory is accessible only by root and the mail group. The /usr/bin/ssmtp binary runs as the mail group and can read this file. There is no reason to add yourself or other users to the mail group.

    Sending email

    To send email from the terminal, do:

    or interactively as:

    An alternate method for sending emails is to create a text file and send it with ssmtp or mail

    Send the test-mail.txt file

    Some users might prefer the syntax of mail from s-nail , mailutils , or other mailx providers instead. For example, mail has options to provide the subject as an argument. mail requires sendmail and can use ssmtp AUR as sendmail.

    Attachments

    If you need to be able to add attachments, install and configure Mutt and Msmtp and then go see the tip at nixcraft.

    Alternatively, you can attach using uuencode from sharutils . To attach ‘file.txt’ as ‘myfile.txt’:

    Mail to Local Users

    Messages sent to local users (or any other address not ending in @fqdn are treated in one of two ways

    • destination user has UID [email protected] in /etc/ssmtp/ssmtp.conf
    • destination user has UID ≥ 1000 or the user is unknown – The the value from rewriteDomain= in /etc/ssmtp/ssmtp.conf is appended to the end of the user id.

    This can lead to problems if local users on your system are not also valid users at your rewriteDomain , but are receiving mail from system services, esp if your rewrite domain is a public service like gmail.com .

    To work around this, you can use mail from s-nail . The mail command can read aliases defined in /etc/mail.rc . Example:

    You can then pipe messages into mail instead of into sendmail.

    I followed online tutorial to set up Email SMTP server in airflow.cfg as below:

    And my DAG is as below:

    I assumed the email operator will run after the other two operators and then send me an email. But email was not sent to me. I really appreciate your help. Thank you very much.

    How to setup email alerts on linux using gmail or smtp

    3 Answers 3

    Setting up SMTP Server for Airflow Email alerts using Gmail:

    Create an email id from which you want to send alerts about DAG failure or if you want to use EmailOperator. Edit airflow.cfg file to edit the smtp details for the mail server.

    For demo you can use any gmail account.

    Create a google App Password for your gmail account. [Instruction here] This is done so that you don’t use your original password or 2 Factor authentication.

    1. Visit your App passwords page. You may be asked to sign in to your Google Account.
    2. At the bottom, click Select app and choose the app you’re using.
    3. Click Select device and choose the device you’re using.
    4. Select Generate.
    5. Follow the instructions to enter the App password (the 16 character code in the yellow bar) on your device.
    6. Select Done.

    Once you are finished, you won’t see that App password code again. However, you will see a list of apps and devices you’ve created App passwords for.

    Edit airflow.cfg and edit the [smtp] section as shown below:

    Edit the below parameters to the corresponding values:

    YOUR_EMAIL_ADDRESS = Your Gmail address
    16_DIGIT_APP_PASSWORD = The App password generated above

    Before QTS 4.2.0

    1. When Gmail is set as an SMTP Server, you may see the following error message when trying to send a test email.

    How to setup email alerts on linux using gmail or smtp

    2. Log in to your Gmail account and you will see a “Sign in attempt prevented” error message.

    How to setup email alerts on linux using gmail or smtp

    3. You will need to change the “Privacy” settings of your Gmail account.

    How to setup email alerts on linux using gmail or smtp

    4. Choose “My Account”.

    How to setup email alerts on linux using gmail or smtp

    5. Choose “Sign-in & security” > “Connected apps & sites”.

    How to setup email alerts on linux using gmail or smtp

    6. Enable “Allow less secure apps”.

    How to setup email alerts on linux using gmail or smtp

    7. After changing this setting, retry sending a test email and it should work.

    How to setup email alerts on linux using gmail or smtp

    After QTS 4.2.1

    QTS 4.2.1 requires OAuth 2.0 authentication for Gmail accounts. You can use this mechanism directly to solve this problem.

    1. Go to “Control Panel” > “Notification” > “E-mail” and set the e-mail account to Gmail.

    How to setup email alerts on linux using gmail or smtp

    2. Click “Add account” to start OAuth 2.0 authentication for Gmail. In the verification page, choose the account you want to use and then click “Allow” to finish the process.

    How to setup email alerts on linux using gmail or smtpHow to setup email alerts on linux using gmail or smtp

    3. The system will automatically help you to enter your e-mail address. If you want to change the account, click “Change account” and go through the same process in Step 2.