Created
June 24, 2014 13:13
-
-
Save RMDK/75e1bf224e47db0f9a78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"metadata": {}, | |
"cell_type": "heading", | |
"source": "Sending SMS and Email Easily with python", | |
"level": 1 | |
}, | |
{ | |
"metadata": {}, | |
"cell_type": "markdown", | |
"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\nEmail me: <a href=\"mailto:email.ryan.kelly@gmail.com?Subject=Hey\" target=\"_top\">email.ryan.kelly@gmail.com</a>" | |
}, | |
{ | |
"metadata": {}, | |
"cell_type": "heading", | |
"source": "\nSending email with gmail and python", | |
"level": 2 | |
}, | |
{ | |
"metadata": {}, | |
"cell_type": "code", | |
"input": "import smtplib\n\nfrom_add = \"your_gmail@gmail.com\"\nto_addr = \"recipient@email.com\"\nmsg = \"This message was sent with python!\"\n\nusername = \"your gmail username\"\npassword = \"password\"\n\n# Start the server using gmail's servers\nserver = smtplib.SMTP('smtp.gmail.com:587')\nserver.starttls()\nserver.login(username, password)\nserver.sendmail(from_add, from_add, msg)\n\n# Log off\nserver.quit()", | |
"prompt_number": 0, | |
"outputs": [], | |
"language": "python", | |
"trusted": true, | |
"collapsed": false | |
}, | |
{ | |
"metadata": {}, | |
"cell_type": "markdown", | |
"source": "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>\n" | |
}, | |
{ | |
"metadata": {}, | |
"cell_type": "heading", | |
"source": "Sending SMS with python and twilio", | |
"level": 2 | |
}, | |
{ | |
"metadata": {}, | |
"cell_type": "markdown", | |
"source": "First you will have to signup for the <a href = \"https://www.twilio.com/try-twilio\">free trial account</a>" | |
}, | |
{ | |
"metadata": {}, | |
"cell_type": "code", | |
"input": "from twilio.rest import TwilioRestClient\n \n# Your Account Sid and Auth Token from twilio.com/user/account\naccount_sid = \"####\"\nauth_token = \"####\"\nclient = TwilioRestClient(account_sid, auth_token)\n \nmessage = 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\nprint message.sid # Check send confirmation", | |
"outputs": [], | |
"language": "python", | |
"trusted": true, | |
"collapsed": false | |
}, | |
{ | |
"metadata": {}, | |
"cell_type": "markdown", | |
"source": "Link to the twilio <a target=\"_parent\" href = \"https://www.twilio.com/docs/api\"> website API</a>." | |
} | |
], | |
"metadata": {} | |
} | |
], | |
"metadata": { | |
"gist_id": "75e1bf224e47db0f9a78", | |
"name": "", | |
"signature": "sha256:df35e0957e3868dc46fed50afd0b4cfbec9f8cf723273fcffd456b2cce53a14c" | |
}, | |
"nbformat": 3 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment