示例代码有问题啊
Topic sourcemsg 信息不全
from email.header import Header
msg['Subject'] = Header('放假通缉', 'utf-8')
msg['From'] = 'xxxxx@163.com>'
msg['To'] = "&&&&&&&@qq.com"
加上这些 就可以了
请问发送成功了么?我也是用163的邮箱,在创建SMTP server的时候总是返回失败,不解。
server = smtplib.SMTP(smtp_server, 25) # SMTP协议默认端口是25
gaierror Traceback (most recent call last)
<ipython-input-13-a4ad37ee429c> in <module>() ----> 1 server = smtplib.SMTP(smtp_server, 25) # SMTP协议默认端口是25 2 server.set_debuglevel(1) 3 server.login(from_addr, password) 4 server.sendmail(from_addr, [to_addr], msg.as_string()) 5 server.quit()
C:\Users\asky0\Anaconda3\lib\smtplib.py in init(self, host, port, local_hostname, timeout, source_address) 249 250 if host: --> 251 (code, msg) = self.connect(host, port) 252 if code != 220: 253 raise SMTPConnectError(code, msg)
C:\Users\asky0\Anaconda3\lib\smtplib.py in connect(self, host, port, source_address) 333 if self.debuglevel > 0: 334 self._print_debug('connect:', (host, port)) --> 335 self.sock = self._get_socket(host, port, self.timeout) 336 self.file = None 337 (code, msg) = self.getreply()
C:\Users\asky0\Anaconda3\lib\smtplib.py in _get_socket(self, host, port, timeout) 304 self._print_debug('connect: to', (host, port), self.source_address) 305 return socket.create_connection((host, port), timeout, --> 306 self.source_address) 307 308 def connect(self, host='localhost', port=0, source_address=None):
C:\Users\asky0\Anaconda3\lib\socket.py in create_connection(address, timeout, source_address) 691 host, port = address 692 err = None --> 693 for res in getaddrinfo(host, port, 0, SOCK_STREAM): 694 af, socktype, proto, canonname, sa = res 695 sock = None
C:\Users\asky0\Anaconda3\lib\socket.py in getaddrinfo(host, port, family, type, proto, flags) 730 # and socket type values to enum constants. 731 addrlist = [] --> 732 for res in _socket.getaddrinfo(host, port, family, type, proto, flags): 733 af, socktype, proto, canonname, sa = res 734 addrlist.append((_intenum_converter(af, AddressFamily),
gaierror: [Errno 11001] getaddrinfo failed
我也遇到这个问题,做实验发送的内容雷同的邮件会被判定为垃圾邮件
#在这里我推荐一个模块pip install faker 释义:骗子,冒牌货.顾名思义,这是一个睁着眼睛说假话的模块. import faker fkr = faker.Faker() fkr.first_name() 返回一个随机假冒的firstname fkr.last_name() 返回一个随机假冒的lastname fkr.company() 返回一个随机假冒的company名称 fkr.paragraphs() 返回一个随机生成的段落
然后,我firstname填到发件人那里 把lastname填到收件人那里 把company填到主题那里 把段落填到正文里边
从此做实验轻松愉快了许多...
- 1
- 2
南海的椰子
我用163邮箱向qq邮箱发邮件,报错:
我按照网页查看了163的错误代码,意思是:
这个问题怎么解决,老师为什么能发出去???