我正在使用Django 1.7.7和简单的代码发送邮件:
def sendEmailToAdmins(subject, msg):
send_mail(subject, msg, settings.INFO_EMAIL,
ADMIN_EMAILS, fail_silently=False)
它运行良好,但是现在我遇到了麻烦:
File "parser.py", line 1264, in <module>
sendEmailToAdmins(subject, msg)
File "/data/parser/immo/../../site/front/utils.py", line 9, in sendEmailToAdmins
ADMIN_EMAILS, fail_silently=False)
File "/usr/local/lib/python2.7/dist-packages/django/core/mail/__init__.py", line 62, in send_mail
return mail.send()
File "/usr/local/lib/python2.7/dist-packages/django/core/mail/message.py", line 286, in send
return self.get_connection(fail_silently).send_messages([self])
File "/usr/local/lib/python2.7/dist-packages/django/core/mail/backends/smtp.py", line 92, in send_messages
new_conn_created = self.open()
File "/usr/local/lib/python2.7/dist-packages/django/core/mail/backends/smtp.py", line 50, in open
self.connection = connection_class(self.host, self.port, **connection_params)
File "/usr/lib/python2.7/smtplib.py", line 251, in __init__
(code, msg) = self.connect(host, port)
File "/usr/lib/python2.7/smtplib.py", line 311, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python2.7/smtplib.py", line 286, in _get_socket
return socket.create_connection((host, port), timeout)
File "/usr/lib/python2.7/socket.py", line 571, in create_connection
raise err
socket.error: [Errno 97] Address family not supported by protocol
PS。没有对linux或Django设置进行任何更改。电子邮件发送到@ gmail.com