In this post, we describe how to send email in pcDuino by script and Python.
First let us look at send email by script:
Install the packages:
1
2 3 |
$sudo apt-get install ssmtp
|
Next we configure SSMTP:
1
|
$sudo nano /etc/ssmtp/ssmtp.conf
|
Now we edit the fields,
1
2 3 4 5 |
AuthUser=youruserid@gmail.com
|
To send email, using:
1
|
$echo "sample text" | mail -s "Subject" username@domain.tld
|
If we want to send email with attachment,
1
|
$mpack -s "test" /home/pi/test/somefile.ext username@domain.tld
|
Now we begin to look at the Python script used to send email:
01
02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
#!/usr/bin/python
|
To run the code, copy the above code and save to reportbyemail.py do:
1
|
$python reportbyemail.py
|
We will then receive the email:
