Hi everyone:
I am currently testing my Sendmail code on a local machine (on
localhost), which is similar to djangobook chapter 14: other
contributed sub-frameworks, the codes are below:
python manage shell
from django.contrib.auth.models import User
email = '
xuexia...@gmail.com'
username = 'xiaodong'
password = 'xiaodong'
new_user = User.objects.create_user(username, password, email)
new_user.save()
from django.core.mail import send_mail
from django.contrib.sites.models import Site
current_site = Site.objects.get_current()
send_mail('Thanks for subscribing to %s alerts' %
current_site.name,
'Thanks for your subscription. We appreciate it.\n\n-The %s team.' %
current_site.name, 'editor@%s' % current_site.domain,
[new_user.email])
However, i had some error message as below:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/django/core/mail.py", line
49, in send_mail
return send_mass_mail([[subject, message, from_email,
recipient_list]], fail_silently, auth_user, auth_password)
File "/usr/lib/python2.5/site-packages/django/core/mail.py", line
66, in send_mass_mail
server = smtplib.SMTP(settings.EMAIL_HOST, settings.EMAIL_PORT)
File "smtplib.py", line 244, in __init__
(code, msg) = self.connect(host, port)
File "smtplib.py", line 310, in connect
raise socket.error, msg
error: (111, 'Connection refused')
it's about the smtp server or it's can not run on a local machine?
Thanks a lot
Dong