So I'm trying to send an email through SMTPlib with Python, but I can't get it to work. I read up on the Microsoft SMTP specs, and put them in accordingly, but I can't get it to work. Here is my code:
# Send an email SERVER = "smtp-mail.outlook.com" PORT = 587 USER = "******@outlook.com" PASS = "myPassWouldBeHere" FROM = USER TO = ["******@gmail.com"] SUBJECT = "Test" MESSAGE = "Test" message = """\ From: %s To: %s Subject: %s %s """ % (FROM, ", ".join(TO), SUBJECT, MESSAGE) try: server = smtplib.SMTP() server.connect(SERVER, PORT) server.starttls() server.login(USER,PASS) server.sendmail(FROM, TO, message) server.quit() except Exception as e: print e print "\nCouldn't connect." I got the code from a keylogger, but I cleaned it up a bit. I read up here on how basic SMTP works, but there are few things like starttls (Methods) I don't quite understand.
I really appreciate any help with this.
emaillibrary to create an actually valid SMTP message; pasting together strings only works when your message is trivial, and/or you know exactly what you are doing.