连接超时问题在Django发送电子邮件 [英] Connection timeout issue sending email in Django
问题描述
我从
http://www.packtpub.com/article/friends-via-email-social-web-application-django-1.0
并按照以下步骤:
=>并更改我的
setting.py
and follow the steps: => And change my setting.py
SITE_HOST = '127.0.0.1:8000'
DEFAULT_FROM_EMAIL = 'KSO Publisher <soeng@xxxx.com.kh>'
EMAIL_HOST = 'smtp.xxxx.com.kh'
EMAIL_PORT = '25'
EMAIL_HOST_USER = 'myusernamea@xxxx.com.kh'
EMAIL_HOST_PASSWORD = 'mypassword'
EMAIL_USE_TLS = False
在我去命令行之后
python@python-desktop:~/workspace/kso$ python manage.py shell
Python 2.5.2 (r252:60911, Jul 22 2009, 15:35:03)
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.core.mail import send_mail
>>> emails = send_mail('Subject', 'Body of the message.','soeng@xxxx.com.kh',['pythonkhmer@gmail.com'])
我收到错误消息。
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/var/lib/python-support/python2.5/django/core/mail.py", line 345, in send_mail
connection=connection).send()
File "/var/lib/python-support/python2.5/django/core/mail.py", line 271, in send
return self.get_connection(fail_silently).send_messages([self])
File "/var/lib/python-support/python2.5/django/core/mail.py", line 166, in send_messages
new_conn_created = self.open()
File "/var/lib/python-support/python2.5/django/core/mail.py", line 131, in open
local_hostname=DNS_NAME.get_fqdn())
File "/usr/lib/python2.5/smtplib.py", line 244, in __init__
(code, msg) = self.connect(host, port)
File "/usr/lib/python2.5/smtplib.py", line 310, in connect
raise socket.error, msg
error: (110, 'Connection timed out')
任何人都知道究竟是什么问题。我如何使用django框架发送邮件
Anybody know what exactly the problem.And how Can I sent mail using django framworks
参考我已阅读:
- http:/ /docs.djangoproject.com/en/dev/topics/email/#the-emailmessage-and-smtpconnection-classes
- http://ltslashgt.com/2007/07/02/gmail-and-django/
- http://bakingnoodles.com/2009/03/command-line-email-with-django-and-gmail/comment-page-1/#comment-432
- http://docs.djangoproject.com/en/dev/topics/email/#the-emailmessage-and-smtpconnection-classes
- http://ltslashgt.com/2007/07/02/gmail-and-django/
- http://bakingnoodles.com/2009/03/command-line-email-with-django-and-gmail/comment-page-1/#comment-432
推荐答案
连接超时表示Django无法连接到您的电子邮件服务器。
在命令行中输入:
'Connection timed out' means Django couldn't connect to your email server. Type this on a command line:
telnet smtp.xxxx.com.kh 25
您应该收到电子邮件服务器的回复,如:
You should get a response from the email server, something like:
220 rufus Python SMTP proxy version 0.2
你得到一个回应,你发现了这个问题。
If you don't get a response,you have found the problem.
这是一个方便的命令来运行本地开发服务器,在Linux上:
Here's a handy command to run a local development server, on Linux:
sudo /usr/lib/python2.6/smtpd.py -n -c DebuggingServer 127.0.0.1:25
这篇关于连接超时问题在Django发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!