Advertisement
Guest User

Untitled

a guest
Dec 16th, 2015
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. import smtplib
  2.  
  3. def sendemail(from_addr, to_addr_list, cc_addr_list,
  4. subject, message,
  5. login, password,
  6. smtpserver='smtp.gmail.com:587'):
  7. header = 'From: %sn' % from_addr
  8. header += 'To: %sn' % ','.join(to_addr_list)
  9. header += 'Cc: %sn' % ','.join(cc_addr_list)
  10. header += 'Subject: %snn' % subject
  11. message = header + message
  12.  
  13. server = smtplib.SMTP(smtpserver)
  14. server.starttls()
  15. server.login(login,password)
  16. problems = server.sendmail(from_addr, to_addr_list, message)
  17. server.quit()
  18.  
  19. sendemail(from_addr = 'python@RC.net',
  20. to_addr_list = ['example@gmail.com'],
  21. cc_addr_list = ['example@gmail.com'],
  22. subject = 'Howdy',
  23. message = 'Hello!',
  24. login = 'example@gmail.com',
  25. password = 'XXXX')
  26.  
  27. Traceback (most recent call last):
  28. File "User/Python/Email.py", line 27, in <module>
  29. password = 'lollol69')
  30. File "User/Python/Email.py", line 15, in sendemail
  31. server = smtplib.SMTP(smtpserver)
  32. File "C:Python34libsmtplib.py", line 242, in __init__
  33. (code, msg) = self.connect(host, port)
  34. File "C:Python34libsmtplib.py", line 321, in connect
  35. self.sock = self._get_socket(host, port, self.timeout)
  36. File "C:Python34libsmtplib.py", line 292, in _get_socket
  37. self.source_address)
  38. File "C:Python34libsocket.py", line 509, in create_connection
  39. raise err
  40. File "C:Python34libsocket.py", line 500, in create_connection
  41. sock.connect(sa)
  42. TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
  43.  
  44. import smtplib
  45.  
  46. def sendemail(from_addr, to_addr_list, cc_addr_list,
  47. subject, message,
  48. login, password,
  49. smtpserver='smtp.gmail.com', smtpport=587): # split smtpserver and -port
  50. header = 'From: %sn' % from_addr
  51. header += 'To: %sn' % ','.join(to_addr_list)
  52. header += 'Cc: %sn' % ','.join(cc_addr_list)
  53. header += 'Subject: %snn' % subject
  54. message = header + message
  55.  
  56. server = smtplib.SMTP(smtpserver, smtpport) # use both smtpserver and -port
  57. server.starttls()
  58. server.login(login,password)
  59. problems = server.sendmail(from_addr, to_addr_list, message)
  60. server.quit()
  61.  
  62. sendemail(from_addr = 'python@RC.net',
  63. to_addr_list = ['example@gmail.com'],
  64. cc_addr_list = ['example@gmail.com'],
  65. subject = 'Howdy',
  66. message = 'Hello!',
  67. login = 'example@gmail.com',
  68. password = 'XXXX')
  69.  
  70. Traceback (most recent call last):
  71. File "UserComputingEmail.py", line 25, in <module>
  72. password = 'lollol69')
  73. File "UserComputingEmail.py", line 13, in sendemail
  74. server = smtplib.SMTP(smtpserver, smtpport) # use both smtpserver and -port
  75. File "C:Python34libsmtplib.py", line 242, in __init__
  76. (code, msg) = self.connect(host, port)
  77. File "C:Python34libsmtplib.py", line 321, in connect
  78. self.sock = self._get_socket(host, port, self.timeout)
  79. File "C:Python34libsmtplib.py", line 292, in _get_socket
  80. self.source_address)
  81. File "C:Python34libsocket.py", line 509, in create_connection
  82. raise err
  83. File "C:Python34libsocket.py", line 500, in create_connection
  84. sock.connect(sa)
  85. TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement