Python Programming for Raspberry Pi, Sams Teach Yourself in 24 Hours

(singke) #1
59: smtpserver.sendmail(sender, tolist, message)
60: smtpserver.quit()
61: self.body.delete('1.0', END)
62: self.body.insert(END, 'Message sent')
63:
64: root = Tk()
65: root.title('The Quick E-mailer')
66: root.geometry('500x300')
67: app = Application(root)
68: app.mainloop()


  1. In lines 41–44, replace the server, port, sender, and password variable
    values with the information required for your email server.

  2. Save the file.

  3. Open the LXTerminal session in your LXDE desktop on the Raspberry Pi.

  4. Run the script2001.py program from the command line, like this:
    Click here to view code image
    pi@raspberrypi ~ $ python3 script2001.py


You should see the window interface, as shown in Figure 20.2.

FIGURE 20.2 The Quick E-mailer application main window.

To send your message to multiple recipients, you just place a comma after each recipient in the To
line. The code uses the split() string method to split the comma-delimited string into a list that the
sendmail() method uses.


Watch Out!: Advanced Security in Gmail
GMail offers an advanced security feature that requires a two-step authentication
process. This method won’t work with that feature in GMail. It only works with a
standard userid/password security.
Free download pdf