{ "metadata": { "gist_id": "75e1bf224e47db0f9a78", "name": "", "signature": "sha256:c5d99d67976162bc263ee67c3eaf760fd49f78062490e73b513766036fb4da4c" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Sending SMS and Email Easily with python" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "I wanted to quickly share the some quick start documentation for these two simple, yet powerful tasks, take a look. In just a few lines of code you could include email and sms messaging within your application.\n", "\n", "Email me: email.ryan.kelly@gmail.com" ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "\n", "Sending email with gmail and python" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import smtplib\n", "\n", "from_add = \"your_gmail@gmail.com\"\n", "to_addr = \"recipient@email.com\"\n", "msg = \"This message was sent with python!\"\n", "\n", "username = \"your gmail username\"\n", "password = \"password\"\n", "\n", "# Start the server using gmail's servers\n", "server = smtplib.SMTP('smtp.gmail.com:587')\n", "server.starttls()\n", "server.login(username, password)\n", "server.sendmail(from_add, from_add, msg)\n", "\n", "# Log off\n", "server.quit()" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 0 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Feel free to try adding HTML messages and attachments using the python documentation\n" ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Sending SMS with python and twilio" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First you will have to signup for the free trial account" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from twilio.rest import TwilioRestClient\n", " \n", "# Your Account Sid and Auth Token from twilio.com/user/account\n", "account_sid = \"####\"\n", "auth_token = \"####\"\n", "client = TwilioRestClient(account_sid, auth_token)\n", " \n", "message = client.messages.create(\n", " body=\"Hey Caity, I'm sending this from my computa!\",\n", " to=\"+######\", # Replace with your recipient's phone number\n", " from_=\"+######\") # Replace with your Twilio number\n", "print message.sid # Check send confirmation" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Link to the twilio website API." ] } ], "metadata": {} } ] }