Bodgers – Texts & Emails

This week we looked at sending texts and emails from our python scripts.

To send text messages you will need to set up an account on Twilio which is a platform that allows coders to make and receive phone calls, send and receive text messages from their programmes. You then install the Twilio python library which will allow us to send texts from our script using code like this.

# Download the helper library from
from import Client

# Your Account Sid and Auth Token from
# DANGER! This is insecure. See
account_sid = 'your account_sid'
auth_token = 'your auth_token'
client = Client(account_sid, auth_token)

message = client.messages \
                     body="Hello Bodgers",


To send an email we use smtplib which is an email library that’s built into python and which works well with Gmail. We need to change our Gmail setting to allow insecure apps and then we can use the code below to send our message.

import smtplib

server = smtplib.SMTP('', 485)
server.login("", "myPassword")

msg = "Hello World"
server.sendmail("", "", msg)

See you all on Saturday

Declan, Dave and Alaidh