Sending SMS and Email Easily with python

Sending email with gmail and python

In [0]:
import smtplib

from_add = "[email protected]"
to_addr = "[email protected]"
msg = "This message was sent with python!"

username = "your gmail username"
password = "password"

# Start the server using gmail's servers
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(username, password)
server.sendmail(from_add, from_add, msg)

# Log off
server.quit()

Feel free to try adding HTML messages and attachments using the<a target="_parent" href = "https://docs.python.org/2/library/email-examples.html"> python documentation</a>

Sending SMS with python and twilio

First you will have to signup for the <a href = "https://www.twilio.com/try-twilio">free trial account</a>

In [ ]:
from twilio.rest import TwilioRestClient
 
# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "####"
auth_token  = "####"
client = TwilioRestClient(account_sid, auth_token)
 
message = client.messages.create(
    body="Hey Caity, I'm sending this from my computa!",
    to="+######",    # Replace with your recipient's phone number
    from_="+######") # Replace with your Twilio number
print message.sid # Check send confirmation

Link to the twilio <a target="_parent" href = "https://www.twilio.com/docs/api"> website API</a>.