Skip to main content
Chemistry LibreTexts

3b.9: Sending email without

  • Page ID
  • \( \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}}} \)

    Raspi Directory Structure

    This is your first assignment and it is imperative that you organize your files in a functional directory (folder) structure.  I suggest the following hierarchy:

    1. Desktop
      1. 2024_pcomp (create a folder on your desktop called "2024_pcomp")
        1. Assn_#on (create folders for each assignment within the 2024_pcomp folder, in this case create one for Asn_7)
        2. Cron (create a folder called "cron" in your class folder). We will place in this folder files that use cron jobs, and this assignment will include some of those.

    Before proceeding you must set up a Google account for this class.   You have two options, open Thonny and paste the following code in the IDE and then save to the Assn_7, or download the file from GitHub.  Now the file from Git Hub will be color coded based on your IDE settings, and anything in parenthesis will be green.  You only need to change 3 red items in the code below.  BUT, internet security is an ongoing battle and the email password that allows third party applications (apps) like this program are of concern to Google, and so they are continually improving their services, which means what worked yesterday may not work tomorrow.

    import smtplib
    from email.mime.text import MIMEText
    from email.mime.multipart import MIMEMultipart
    from email.mime.base import MIMEBase
    from email import encoders
    email_user = "type here"
    email_password ="type here your_iost_account@ gmail KEY here"
    email_send = "type here the email_address you want to send an email to"
    subject = "type here the subject line of your email"
    msg = MIMEMultipart()
    msg["From"] = email_user
    msg["To"] = email_send
    msg["Subject"] = subject
    body = "Type here the message you wish to send"
    text = msg.as_string()
    server = smtplib.SMTP("",587)

    Using GitHub on raspi

    Open Chromium on your raspberry Pi and go to


    New Figure \(\PageIndex{1}\): Copy and Paste Caption here. (Copyright; author via source)

    Open the S2024_PhysComp-REPO, navigate to the 7-Getting-started-with-Raspi folder and open the file and then chose the download option

    clipboard_eb1797c7a4f73df77eabb103bebb36bba.pngFigure \(\PageIndex{1}\): Copy and Paste Caption here. (Copyright; author via source)


    Open the downloads folder and move the file to the /home/username/Desktop.2024_Pcomp/Asn_7

    clipboard_e02c3b8906aebe21f3d5e7ecc1552f30d.pngFigure \(\PageIndex{1}\): Copy and Paste Caption here. (Copyright; author via source)


    clipboard_e6a4d588b2f8200916a6761e3f0d15d76.pngFigure \(\PageIndex{1}\): Copy and Paste Caption here. (Copyright; author via source)

    Open the file in Thonny and change the text in lines 7,8,9,11, and 18.

    clipboard_e4d2d0f3916b8d100b159e2b9230a6f0b.pngFigure \(\PageIndex{1}\): Copy and Paste Caption here. (Copyright; author via source)



    This page titled 3b.9: Sending email without is shared under a not declared license and was authored, remixed, and/or curated by Robert Belford.

    • Was this article helpful?