Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import smtplib
- def sendemail(from_addr, to_addr_list, cc_addr_list,
- subject, message,
- login, password,
- smtpserver='smtp.gmail.com:587'):
- header = 'From: %sn' % from_addr
- header += 'To: %sn' % ','.join(to_addr_list)
- header += 'Cc: %sn' % ','.join(cc_addr_list)
- header += 'Subject: %snn' % subject
- message = header + message
- server = smtplib.SMTP(smtpserver)
- server.starttls()
- server.login(login,password)
- problems = server.sendmail(from_addr, to_addr_list, message)
- server.quit()
- sendemail(from_addr = 'python@RC.net',
- to_addr_list = ['example@gmail.com'],
- cc_addr_list = ['example@gmail.com'],
- subject = 'Howdy',
- message = 'Hello!',
- login = 'example@gmail.com',
- password = 'XXXX')
- Traceback (most recent call last):
- File "User/Python/Email.py", line 27, in <module>
- password = 'lollol69')
- File "User/Python/Email.py", line 15, in sendemail
- server = smtplib.SMTP(smtpserver)
- File "C:Python34libsmtplib.py", line 242, in __init__
- (code, msg) = self.connect(host, port)
- File "C:Python34libsmtplib.py", line 321, in connect
- self.sock = self._get_socket(host, port, self.timeout)
- File "C:Python34libsmtplib.py", line 292, in _get_socket
- self.source_address)
- File "C:Python34libsocket.py", line 509, in create_connection
- raise err
- File "C:Python34libsocket.py", line 500, in create_connection
- sock.connect(sa)
- 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
- import smtplib
- def sendemail(from_addr, to_addr_list, cc_addr_list,
- subject, message,
- login, password,
- smtpserver='smtp.gmail.com', smtpport=587): # split smtpserver and -port
- header = 'From: %sn' % from_addr
- header += 'To: %sn' % ','.join(to_addr_list)
- header += 'Cc: %sn' % ','.join(cc_addr_list)
- header += 'Subject: %snn' % subject
- message = header + message
- server = smtplib.SMTP(smtpserver, smtpport) # use both smtpserver and -port
- server.starttls()
- server.login(login,password)
- problems = server.sendmail(from_addr, to_addr_list, message)
- server.quit()
- sendemail(from_addr = 'python@RC.net',
- to_addr_list = ['example@gmail.com'],
- cc_addr_list = ['example@gmail.com'],
- subject = 'Howdy',
- message = 'Hello!',
- login = 'example@gmail.com',
- password = 'XXXX')
- Traceback (most recent call last):
- File "UserComputingEmail.py", line 25, in <module>
- password = 'lollol69')
- File "UserComputingEmail.py", line 13, in sendemail
- server = smtplib.SMTP(smtpserver, smtpport) # use both smtpserver and -port
- File "C:Python34libsmtplib.py", line 242, in __init__
- (code, msg) = self.connect(host, port)
- File "C:Python34libsmtplib.py", line 321, in connect
- self.sock = self._get_socket(host, port, self.timeout)
- File "C:Python34libsmtplib.py", line 292, in _get_socket
- self.source_address)
- File "C:Python34libsocket.py", line 509, in create_connection
- raise err
- File "C:Python34libsocket.py", line 500, in create_connection
- sock.connect(sa)
- 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