【问题标题】:django sending emailsdjango 发送邮件
【发布时间】:2011-03-02 02:57:45
【问题描述】:

嘿,我似乎无法使用 send_mail() 发送电子邮件,我不知道为什么。

这是我的详细信息

settins.py

EMAIL_HOST = 'localhost',
EMAIL_PORT = 25

我的看法

from django.core.mail import send_mail

send_mail('Subject here', 'Here is the message.', 'from@example.com',
    ['to@example.com'], fail_silently=False)

这会失败并出现错误

getaddrinfo() argument 1 must be string or None

有人有什么想法吗?

我正在 OS X Leopard 上开发

这是最后的回溯

/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/smtplib.py in connect
for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM): ...
▼ Local vars
Variable    Value
host    ('localhost',)
msg     'getaddrinfo returns an empty list'
port    25
self    <smtplib.SMTP instance at 0x153b1e8>

【问题讨论】:

    标签: django email send


    【解决方案1】:

    EMAIL_HOST 之后的逗号使它成为长度为 1 的元组,而不是字符串。去掉杂散的逗号。

    【讨论】:

    • 就这样我的问题解决了!非常感谢!
    猜你喜欢
    • 2016-01-28
    • 2019-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-18
    • 2013-04-17
    • 2016-02-15
    • 2021-03-11
    相关资源
    最近更新 更多