Advertisement
Guest User

Untitled

a guest
May 13th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. Traceback (most recent call last):
  2. File "StackOverflow/multipart_email.py", line 41, in <module>
  3. main()
  4. File "StackOverflow/multipart_email.py", line 35, in main
  5. server.login(input('Username: '), input('Password: '))
  6. File "Python35libsmtplib.py", line 730, in login
  7. raise last_exception
  8. File "Python35libsmtplib.py", line 721, in login
  9. initial_response_ok=initial_response_ok)
  10. File "Python35libsmtplib.py", line 627, in auth
  11. initial_response = (authobject() if initial_response_ok else None)
  12. File "Python35libsmtplib.py", line 664, in auth_login
  13. raise SMTPAuthenticationError(code, resp)
  14. smtplib.SMTPAuthenticationError: (502, b'5.5.1 Unrecognized command. r134sm2789857qke.10 - gsmtp')
  15.  
  16. #! /usr/bin/env python3
  17. import email.mime.multipart
  18. import email.mime.text
  19. import smtplib
  20.  
  21.  
  22. def main():
  23. message = email.mime.multipart.MIMEMultipart('alternative')
  24. message['From'] = 'Noctis.Skytower@gmail.com'
  25. message['To'] = 'Stephen.P.Chappell@gmail.com'
  26. message['Subject'] = 'Multipart Email'
  27. text = '''
  28. Hi!
  29. How are you?
  30. This is a test for multipart emails.
  31. It is being sent via Python.
  32. https://www.python.org/'''
  33. html = '''
  34. <html>
  35. <head>
  36. <title>Who is going to see this?</title>
  37. </head>
  38. <body>
  39. Hi!<br/>
  40. How are you?<br/>
  41. This is a test for multipart emails.<br/>
  42. It is being sent via <a href="https://www.python.org/">Python</a>.
  43. </body>
  44. </html>'''
  45. message.attach(email.mime.text.MIMEText(text, 'plain'))
  46. message.attach(email.mime.text.MIMEText(html, 'html'))
  47. server = smtplib.SMTP('smtp-relay.gmail.com', 587)
  48. server.ehlo()
  49. server.starttls()
  50. server.login(input('Username: '), input('Password: '))
  51. server.sendmail(message['From'], message['To'], message.as_string())
  52. server.quit()
  53.  
  54.  
  55. if __name__ == '__main__':
  56. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement