Qtum Staking : How to setup RaspBerry Pi email alert when you earned QTUM

in #qtum7 years ago (edited)

Intro


The purpose of this post is share the the setting up screenshots of email alert script for those using Raspberry Pi to staking QTUM.

For a good Qtum Staking Tutorial using qtumd on a Raspberry Pi Click Here

Gmail account Setup


If you are not using gmail for mail relay, you can ignore this section.
Gmail does not allow mail reply using your default login password.
We will need to setup an App Password for this purpose.
Reference : https://support.google.com/accounts/answer/185833?hl=en

Visit https://security.google.com/settings/security/apppasswords
Login with your gmail account & default password.
Select Other & give a name “RaspBerry Pi”

Click GENERATE when done

Copy or save the generated password
(Note : it is a 16 characters string, no space in between)

Install mail utils on Raspberry Pi


Reference : http://www.raspberry-projects.com/pi/software_utilities/email/ssmtp-to-send-emails
sudo apt-get install ssmtp
sudo apt-get install mailutils

Make sure install is successful.
If install failed, try do a sudo apt_get update & repeat above step.

Next do the same install for mailutils

Now edit the SSMTP configuration file
sudo nano /etc/ssmtp/ssmtp.conf
Change the mailhub to your ISP

At the end of line add a few details
[email protected]
AuthPass=TheGmailPassword (this is the gmail password you created above)
FromLineOverride=YES
UseSTARTTLS=YES

When done. Press Ctrl-X to exit & “Y” to save changes, follow by enter

Send a test mail
echo "Hello world email body" | mail -s "Test Subject" [email protected]

You will receive the test email if all went well.

If you have below cannot send message, check your ssmpt.conf or your gmail password.

Setup qtum_monitor.py script


Goto https://github.com/anuzis/qtum_pi_monitor/blob/master/qtum_monitor.py
Copy the python script

Paste it to a text editor
Save the file as qtum_monitor.py

Line no. 23 and 25 are the two lines need to change.
RECIPIENT_EMAIL & QTUM_PATH

Example QTUM_PATH = '/home/pi/qtum-wallet/'

Other changes you may want to tweak is in line 17 & 19

Use nano to create file qtum_monitor.py

Copy the python script from your text editor and paste in nano.
Right click to paste the script.
When done press Ctrl-X, Yes and enter

Test python script

You will receive an email if all go well.

A log file “qtum_monitor.log” will be created in qtum-wallet folder.

Schedule task with Crontab


Execute crontab -e
Choose option 2

Append the schedule into crontab
(Perform hourly check, send an email if there are error or earning)</>
0 * * * * /usr/bin/python /home/pi/qtum_monitor.py

When done, press Ctrl-X, yes and enter

To list your crontab, using crontab -l

Earning Email


When you earn qtum coin, you will receive an email.

Sort:  

if you have a test mail error, like below.
echo "Hello world email body" | mail -s "Test Subject" [email protected]

mail: cannot send message: Process exited with a non-zero status

Check in "ssmtp.conf"
mailhub=smtp.gmail.com:587
is correctly set.

done~! thank you so much!

Coin Marketplace

STEEM 0.16
TRX 0.15
JST 0.029
BTC 57190.65
ETH 2409.68
USDT 1.00
SBD 2.28