Created
February 8, 2018 00:24
-
-
Save sc137/296d35916a4f5f37d7fc27c8db26342c to your computer and use it in GitHub Desktop.
send a plain text email from the terminal
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
#!/usr/local/bin/python3 | |
# | |
# email_o365.py | |
# /sable cantus/ | |
# http://cantus.us/ | |
################### | |
""" | |
https://github.com/Narcolapser/python-o365 | |
$ pip3 install O365 | |
Save your credentials as an environment variable in .profile | |
export o365_email="your_email" | |
export o365_password="your_password" | |
""" | |
import os, sys | |
from O365 import Message | |
fromAddr = os.getenv('o365_email') | |
password = os.getenv('o365_password') | |
toAddrs = input("send to: ") | |
messageSubject = input("subject? ") | |
print("message (Ctrl+D to send): \n") | |
messageBody = sys.stdin.read() | |
authenticiation = (fromAddr, password) | |
m = Message(auth=authenticiation) | |
m.setRecipients(toAddrs) | |
m.setSubject(messageSubject) | |
m.setBody(messageBody) | |
m.sendMessage() | |
print("Message probably sent.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment