Rapbian Sketch
- Page ID
- 207718
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)
( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\id}{\mathrm{id}}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\kernel}{\mathrm{null}\,}\)
\( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\)
\( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\)
\( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)
\( \newcommand{\vectorA}[1]{\vec{#1}} % arrow\)
\( \newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow\)
\( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vectorC}[1]{\textbf{#1}} \)
\( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)
\( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)
\( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)If your Raspberry Pi operating system was installed before July of 2019 you have Raspbian Sketch and are updating that operating system. There are a few differences as that used the smtp and not the msmtp package.
- Install some software on the Pi
First we install the ssmtp and mutt libraries. SSMTP is a program which delivers email from a local computer to a configured mailhost(mailhub). Mutt is a text-based email client for Unix-like systems. Open a terminal window and type the following:
Note
If you hit the uparrow on the command line you get the previous command So after you type one command, hit the update, and edit the line (instead of typing everything)
pi@hostname:~ $sudo apt-get update pi@hostname:~ $sudo apt-get upgrade pi@hostname:~ $sudo apt-get install ssmtp pi@hostname:~ $sudo apt-get install mutt pi@hostname:~ $sudo apt-get install mailutils pi@hostname:~ $sudo apt-get install mpack
-
Configure a file
Next we need to make some configuration changes. We will be using a text editor called nano. This is a simple interface for making changes to the files we need to alter. We need to configure the ssmtp.conf file to indicate that we are using the gmail mail hub. To do so at the command prompt type:
pi@hostname:~ $sudo nano /etc/ssmtp/ssmtp.conf
NOTE you must use sudo to allow you to write the changes
Now, you need to alter line 10 of the file. To get to line 10, hit ctrl_ (control and underscore). You can then type in 10 to jump to that line of code.
You will see that the line reads:
mailhub= mail
change that line of code to read:
mailhub=smtp.gmail.com:587
Find the last line in the file. It has
#FromLineOverride=Yes
Remove the hashtag so it reads
FromLineOverride=YES
Now after the FromLineOverride line, you will add the following lines:
AuthUser=yourgmailaccount@gmail.com AuthPass=yourgmailpassword UseSTARTTLS=YES UseTLS=YES
Save these changes by hitting ctrl-x (control and x simultaneously, when you do this you exit the nano editor and have the option to save changes).
NOTE yourgmailaccount and your password are from the account you just created.
NOTE 2- very important!!!!! You have just hard coded a password here. This is why you create a new account that you will never use for anything else. Anyone who knows how to find this file will know your password.
- First we will test it out using MUTT, a feature-rich command line email client that we installed with the apt-get install mutt line from above. Test it out by typing the following at the prompt. The first line puts you in your home directory, and the second will send an email to the email you specify. In this example, I am using a generic yourstlcopemail@stlcop.edu
- for that address. Be sure to change it to your own!
pi@hostname:~ $cd
pi@hostname:~ $echo email ‘message from your RasPi’|mutt -s ‘subject line from your RasPi’ your-email@yourschool
NOTE: the above is one command line that may take two lines to enter.
NOTE: You may get a line that state GPGME: CMS protocol not available, but the message should send.
NOTE: The pipe character can be found as the shifted key just above the Enter on your computer:
Echo is a standard unit command to write to something to standard output. In this case we are echoing email "message from you RasPi". We are "piping" the output to the mutt mail client. We are telling the mail client what the subject is and the email address to send the mail to.
- Test it again. This time type the following commands. In the second line after –a type the name of one of your python programs you saw after the ls command:
pi@hostname:~ $cd python_programs pi@hostname:~ $ls pi@hostname:~ $ echo email 'file from your RasPi' |mutt -s 'a file from your RasPi' yourschoolemail@your.edu -a one_of_your_programs.py
What showed up in your email? What does the –a do when you add that argument to the command?
7) This time we will test it again using another email utility program that we installed (mailutils). Type the following commands from your current directory:
pi@hostname:~ $ echo "sample text" | mail -s "Subject" yourschoolemail@your.edu pi@hostname:~ $ echo "sample text" | mail -s "Subject" yourschoolemail@your.edu –attach "somefilename.py" pi@hostname:~ $
What showed up in your email? What does the --attach do when you add that argument to the command?