作者materies (说)
看板Python
标题[问题] 发email 问题
时间Mon Jun 4 11:36:31 2018
Traceback (most recent call last):
File "test_7.py", line 28, in <module>
server.send_message(msg)
AttributeError: SMTP_SSL instance has no attribute 'send_message'
请问这error 要如何解
谢谢
附上程式码
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
from PIL import Image #读取#
import numpy as np
import matplotlib.pyplot as plt
import gmpy2
import smtplib
from email.mime.text import MIMEText
gmail_user = '
[email protected]'
gmail_password = 'XXXX' # your gmail password
msg = MIMEText('content')
msg['Subject'] = 'Test'
msg['From'] = gmail_user
msg['To'] = '
[email protected]'
server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
server.ehlo()
server.login(gmail_user, gmail_password)
server.send_message(msg)
server.quit()
print('Email sent!)
********************
--
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 118.163.0.31
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1528083395.A.68A.html
1F:→ kobe8112: 没有send_message这个函式可以让你呼叫 06/04 11:57
2F:→ kobe8112: 你可能需要确认你的模组版本到底有哪些函式可以用 06/04 12:01
3F:→ kobe8112: 或者直接试试/google sendmail这个函式 06/04 12:01
4F:→ materies: 感谢 已经解决 06/04 23:37