Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Traceback (most recent call last):
- File "StackOverflow/multipart_email.py", line 41, in <module>
- main()
- File "StackOverflow/multipart_email.py", line 35, in main
- server.login(input('Username: '), input('Password: '))
- File "Python35libsmtplib.py", line 730, in login
- raise last_exception
- File "Python35libsmtplib.py", line 721, in login
- initial_response_ok=initial_response_ok)
- File "Python35libsmtplib.py", line 627, in auth
- initial_response = (authobject() if initial_response_ok else None)
- File "Python35libsmtplib.py", line 664, in auth_login
- raise SMTPAuthenticationError(code, resp)
- smtplib.SMTPAuthenticationError: (502, b'5.5.1 Unrecognized command. r134sm2789857qke.10 - gsmtp')
- #! /usr/bin/env python3
- import email.mime.multipart
- import email.mime.text
- import smtplib
- def main():
- message = email.mime.multipart.MIMEMultipart('alternative')
- message['From'] = 'Noctis.Skytower@gmail.com'
- message['To'] = 'Stephen.P.Chappell@gmail.com'
- message['Subject'] = 'Multipart Email'
- text = '''
- Hi!
- How are you?
- This is a test for multipart emails.
- It is being sent via Python.
- https://www.python.org/'''
- html = '''
- <html>
- <head>
- <title>Who is going to see this?</title>
- </head>
- <body>
- Hi!<br/>
- How are you?<br/>
- This is a test for multipart emails.<br/>
- It is being sent via <a href="https://www.python.org/">Python</a>.
- </body>
- </html>'''
- message.attach(email.mime.text.MIMEText(text, 'plain'))
- message.attach(email.mime.text.MIMEText(html, 'html'))
- server = smtplib.SMTP('smtp-relay.gmail.com', 587)
- server.ehlo()
- server.starttls()
- server.login(input('Username: '), input('Password: '))
- server.sendmail(message['From'], message['To'], message.as_string())
- server.quit()
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement