我正在尝试使用Python 3.4中的SMTP发送电子邮件,但是当我运行代码时收到以下错误:
Traceback (most recent call last):
File "C:/Users/Anna Hughes/Documents/Python Projects/2015.10.16/Mail Application.py", line 9, in <module>
server.login(user_email, user_password)
File "C:\Python34\lib\smtplib.py", line 613, in login
raise SMTPException("SMTP AUTH extension not supported by server.")
smtplib.SMTPException: SMTP AUTH extension not supported by server.
这是我的代码:
import smtplib
server = smtplib.SMTP("smtp.gmail.com:587")
user_email = "user@gmail.com"
user_password = "password"
recipient_email = "recipient@gmail.com"
msg = "Test."
server.login(user_email, user_password)
server.ehlo()
server.starttls()
server.sendmail(user_email, recipient_email, msg)
server.quit()
感谢。
编辑:
我已根据建议将第二行更改为server = smtplib.SMTP("smpt.gmail.com, 587")
。这似乎解决了错误,但我现在得到一个新错误:
Traceback (most recent call last):
File "C:/Users/Anna Hughes/Documents/Python Projects/2015.10.16/Mail Application.py", line 2, in <module>
server = smtplib.SMTP("smtp.gmail.com,587")
File "C:\Python34\lib\smtplib.py", line 242, in __init__
(code, msg) = self.connect(host, port)
File "C:\Python34\lib\smtplib.py", line 321, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "C:\Python34\lib\smtplib.py", line 292, in _get_socket
self.source_address)
File "C:\Python34\lib\socket.py", line 494, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "C:\Python34\lib\socket.py", line 533, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed
答案 0 :(得分:2)
您还可以尝试yagmail:
import yagmail
yag = yagmail.SMTP("user@gmail.com", "password")
yag.send("recipient@gmail.com", subject="sub", contents="Test.")
使用pip install yagmail
安装。
可以在github页面上找到更多技巧,例如无密码脚本。
答案 1 :(得分:1)
我可以帮忙。
然后
server = smtplib.SMTP("smtp.gmail.com, 587")
server.starttls()
server.login("username","p455w0rd")
答案 2 :(得分:0)
我想也许你的问题就在于此:
server = smtplib.SMTP("smtp.gmail.com:587")
我有一些发送电子邮件的程序,我使用以下格式:
server = smtplib.SMTP("smtp.gmail.com, 587")
如果您最初看不到差异,则冒号已更改为逗号。 希望这能解决它!
答案 3 :(得分:0)
试试这个
import smtplib
Server=smtplib.SMTP('smtp.gmail.com',587)
Server.starttls()
Server.login("EMAIL_YOUR","YOUR_PASSWORD")
msg="Hello, Its the Message!"
Server.sendmail("whom_2_send@gmail.com","your_email@gmail.com",msg)
print("email send succesfully") #Just for confirmation
Server.quit()
答案 4 :(得分:0)
尝试一下:
<script>
export default {
data () {
return {
drawer: false,
show_item: [false, false]
}
},
methods: {
showDrawer () {
// drawer changes state when user clicks on Icone
this.drawer = !this.drawer
if (!this.drawer) { // When the drawer is closed, all title and subtitles are closed
for (let i = 0; i < this.show_item.length; i++) {
this.show_item[i] = false
}
}
},
showItem (arg) {
for (let i = 0; i < this.show_item.length; i++) {
if (i === arg) {
if (!this.show_item[arg]) {
this.drawer = true
}
this.show_item[arg] = !this.show_item[arg]
} else {
this.show_item[i] = false
}
}
console.log(this.show_item)
}
}
}
</script>