WebFaction
Community site: login faq

Hi,

I can't for the life of me configure django to send emails on webfaction. I have the following on my settings.py: (the password is correct on the server, though ;-)

DEBUG = False
SEND_BROKEN_LINK_EMAILS = True
EMAIL_HOST = 'smtp.webfaction.com'
EMAIL_HOST_USER = 'kroger'
EMAIL_HOST_PASSWORD = 'my password'
DEFAULT_FROM_EMAIL = 'bug@quicktestgenerator.com'
SERVER_EMAIL = 'bug@quicktestgenerator.com'

ADMINS = (
    ('Pedro Kroger', 'pedro.kroger@gmail.com'),
)

MANAGERS = ADMINS

I tried to access inexistent pages on my app so django would email me (I have SEND_BROKEN_LINK_EMAILS set to True) but I haven't receive one email. My email setup is working properly (I can send emails to bug@quicktestgenerator.com).

I also tried to send an email using the django shell, to test my settings.py configuration, but I got this error message:

"TypeError: character mapping must return integer, None or unicode" when I issued the following command:

from django.core.mail import send_mail
send_mail(u"test", u"foobar", u"bug@quicktestgenerator.com", [u"pedro.kroger@gmail.com"], fail_silently=False)

Any ideas or suggestions?

asked 02 Aug '11, 10:29

kroger
1314
accept rate: 0%

edited 02 Aug '11, 13:32

Do you have an E-mail address defined in Admins or Managers in your settings.py?

(02 Aug '11, 10:34) bmeyer71 ♦♦

Yes I do. I updated the question to reflect that.

(02 Aug '11, 13:32) kroger

Can you please post the full traceback that appears with the "TypeError: character mapping must return integer, None or unicode" message?

(03 Aug '11, 11:37) seanf

Sure, here's the traceback

Just to clarify, my password is a unicode string:

EMAIL_HOST_PASSWORD = u"mypassword"
(03 Aug '11, 14:14) kroger

I forgot to mention that I'm using virtualenv.

(03 Aug '11, 14:17) kroger

See answer below.

(03 Aug '11, 14:38) seanf
showing 5 of 6 show 1 more comments

I just tested SMTP authentication in bare smtplib, outside of Django, using a unicode password string, and it failed with that same "TypeError: character mapping must return integer, None or unicode" exception , so I think the solution will be to use a regular string, eg EMAIL_HOST_PASSWORD = "mypassword", for your Django SMTP settings.

permanent link

answered 03 Aug '11, 14:37

seanf
12.2k41836
accept rate: 37%

Thanks, that solved it! I could send an email using send_mail on the shell and django is sending emails for broken links.

(03 Aug '11, 14:49) kroger

Are you using pinax? If so you need to set up a a cronjob to run these commands,

http://pinaxproject.com/docs/dev/deployment/#sending-mail-and-notices
permanent link

answered 02 Aug '11, 17:44

johns
5.4k312
accept rate: 23%

No, just plain vanilla django.

(03 Aug '11, 10:18) kroger
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×261

question asked: 02 Aug '11, 10:29

question was seen: 8,562 times

last updated: 03 Aug '11, 14:49

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM