Qtum Staking : How to setup RaspBerry Pi email alert when you earned QTUM
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
![](https://steemitimages.com/DQmWcACGq68jcweYDSrMZy2ynCFFvtU5oAcqggmhRoeUuwG/image.png)
Visit https://security.google.com/settings/security/apppasswords
Login with your gmail account & default password.
Select Other & give a name “RaspBerry Pi”
![](https://steemitimages.com/640x0/https://steemitimages.com/DQmVibiejcszxs92b8M7icYkPyYHuz8AiJjiKgFFGVzrDQ1/image.png)
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
![](https://steemitimages.com/DQmbPysYyCPnQEa4xg3vy4N1F2C1n5pQEG2dpR6112f7zmQ/image.png)
Make sure install is successful.
If install failed, try do a
sudo apt_get update
& repeat above step.![](https://steemitimages.com/640x0/https://steemitimages.com/DQmUTrGUsL7GTMfLLEebTuQbGZfvh2db6R7KRGtBMpdWRGb/image.png)
Next do the same install for mailutils
![](https://steemitimages.com/DQmQHMiNZ8KFsjRPNeFE7j4Sh7PKMoRXLheKURPMCH2QrHU/image.png)
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
![](https://steemitimages.com/640x0/https://steemitimages.com/DQmbMtzkr6ZvsMtzdeHtG4XV1Fg5NtNMWjoznTRn5pXZGPh/image.png)
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
![](https://steemitimages.com/640x0/https://steemitimages.com/DQmXg3ysST7fsdEmZn1w58d4VKFkQUM6Jv9vd6qnRzEJD1y/image.png)
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.
![](https://steemitimages.com/640x0/https://steemitimages.com/DQmeBnoJNotNUpURPDY3dip8gKHYt5DDPbyZ7yNqV1CbWZW/image.png)
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!