Don't miss out on new posts and newsletters, Follow Us by Email

Sunday, 29 November 2020

Command Line Mail setup OpenPlotter

Command Line Mail setup for OpenPlotter2. We use this to send an email triggered by the OpenCPN plugin, Watchdog.  

OpenCPN Watchdog plugin (command function) can execute a command to send out an email, we use this for remote monitoring by Gmail. 

Using SSMTP on openplotter2 to send email, well SSMTP does not seem to work any longer, try as I did, it didnt connect with gmail. 

Eventually I found msmtp as an alternative to SSMPT and I was able to get it up an running in no time and had OpenCPN Watchdog emailing me with alarms.  

First thing I did was open a Gmail account, I use a Gmail account specially for the boat because I needed to change one of the the security settings to be less secure during login. DO NOT use existing accounts or usual passwords because they can be exposed.

Open a new Gmail account and enable:

1. Enabling less secure apps to access Gmail

2. Open your Google Admin console (

3. Click Security > Basic settings .

4. Under Less secure apps, select Go to settings for less secure apps .

5. In the subwindow, select the Enforce access to less secure apps for all users radio button. 

6. Click the Save button.

You can install the msmtp package with:

$sudo apt-get install msmtp msmtp-mta

The configuration file is located here : /etc/msmtprc

Strangely enough, it is empty with no clues, which is different from the old ssmtp.conf file.

However, there is a description with details if you use the man $man msmtp, or just copy and paste the contents I have supplied changing the necessary acount details.

For gmail accounts, these are the specific elements you should put into /etc/msmtprc:  

$sudo nano /etc/msmtprc

# Generics, important tls needs to be on when using port 587
auth           on
tls            on
# following is different from ssmtp:
tls_trust_file /etc/ssl/certs/ca-certificates.crt
# user specific log location, otherwise use /var/log/msmtp.log, however, 
# this will create an access violation if you are user pi, and have not changes the access rights
logfile        ~/.msmtp.log
# Gmail specifics, you shouldnt need to change these
account        gmail
port           587
# You need to change these
password      your-vessel-gmail-account-password
# Default
account default : gmail

Save the file close nano and exit.

You can test if this now works with:

$echo 'your test message' | msmtp

I have not yet found a way to set the subject, there is no -s flag as with ssmpt.

However, if you also install mailutils:

$sudo apt-get install mailutils

Then these should work:

$echo 'message' | mail -s "Hello"

$echo 'message' | sendmail

You can use both mailutils and mpack with msmtp just as you did with ssmtp.

So any scripts that you have used before with ssmtp, mailutils or mpack should work just the same using msmtp.

Setting up the command script file to use in OpenCPN plugin, Watchdog.

 You can have Watchdog execute a computer command. We wanted Watchdog to send us an email if our boat moves or the NMEA data stops. We stored the command to email a boat moving alarm in a shell file called: and for the loss of NMEA data:

First up create a new directory called bin in /home/pi  

$mkdir bin  

Reboot the computer, the bin file will be seen on reboot.

After creating the files with nano $sudo nano and $sudo nano  

Save them to the created /home/pi/bin directory I changed the permissions of the file to make them executable. 

$sudo chmod 755 

$sudo chmod 755

As an example of the file, here is the format of the NMEA data loss script file 

echo "GPS NMEA Data Loss" | mail -s "Danger Will Robertson" 

Or for the Anchor watch script file

echo "Boat appears to be on the move. Best regards, the Watchdog " | mail -s "ON THE MOVE"

You may want to send the email to your most used account that will alarm on your phone when an email is received, we don't send mail to the same account as we receive it from, but this is a personal choice.

Before running the test to check if the shell script works, shutdown and reboot OpenPlotter

 Then test the shell file is going to work. After reboot open a terminal window and type in or 

If these files are working, you receive an email or two, then you can go ahead and configure WatchDog to select these files as a command to execute.


  1. I’m Артур Борис a resident/citizen of the Republic Of Russian. I’m 52 years of age, an entrepreneur/businessman. I once had difficulties in financing my project/business, if not for a good friend of mine who introduced me to Mr Benjamin Lee to get a loan worth $250,000 USD from his company. When I contacted them it took just five working days to get my loan process done and transferred to my account. Even with a bad credit history, they still offer their service to you. They also offer all kinds of loan such as business loans, home loans, personal loans, car loans. I don’t know how to thank them for what they have done for me but God will reward them according to his riches in glory. If you need an urgent financial assistance contact them today via email  WhatsApp information...+1-989-394-3740

  2. Nice Post, CnX Player offers a fantastic Video Casting feature that gives an absolute freedom to all its users to cast ANY (literally ANY) video format and ANY video codec from PC to TV within a fraction of seconds! It is a Best Media Player.

    Features @ CnX Player - Best Media Player

    * Stream ANY video from PC to Chromecast
    * Cast ALL Videos From PC To All Smart TV
    * Stream ANY video from PC to Chromecast
    * Cast Videos from iPhone iPad to Firestick TV
    * Stream any videos from PC to MI TV
    * Cast ALL Videos from PC to Android TV
    * Stream ANY Video From PC To SAMSUNG TV

    For more information visit our website at Best Media Player - CnX Player


  3. This article's content is really unique and amazing. This article really helpful and explained very well. So I am really thankful to you for sharing keep it up..


  4. Thanks for the always useful information. This is great information to help peoples and nice article written by writer. CnX Player is a powerful & efficient 4K ultra HD enabled video player for Windows 10 PC & Tablet, Android and iOS – iPhone & iPad.

    Download Media Player for Windows 10 - Microsoft Store
    Download Video Player for Android from Google Play
    Download Video Player for iPhone/iPad from Apple App Store