Send mail bug needs password passed as bytearray

32 views
Skip to first unread message

ell...@makecollective.co.nz

unread,
Jan 31, 2017, 6:06:04 PM1/31/17
to Django users
myMail = EmailMessage('subject', 'message', 'some...@address.com', ['mye...@address.com'])
myMail.send()

The error I'm getting:

  File "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/message.py", line 342, in send


    return self.get_connection(fail_silently).send_messages([self])


  File "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages


    new_conn_created = self.open()


  File "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 67, in open


    self.connection.login(self.username, self.password)


  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 607, in login


    (code, resp) = self.docmd(encode_cram_md5(resp, user, password))


  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 571, in encode_cram_md5


    response = user + " " + hmac.HMAC(password, challenge).hexdigest()


  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hmac.py", line 75, in __init__


    self.outer.update(key.translate(trans_5C))


TypeError: character mapping must return integer, None or unicode


There was solution from this ticket with the same problem. But then the fixed commit was removed here.

The settings needed to send emails now

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.webfaction.com'
EMAIL_HOST_USER = '****'
EMAIL_HOST_PASSWORD = bytearray('******', 'utf-8')
EMAIL_PORT = 587

So 2 questions:

Am I missing something simple?

Is this a bug and needs a ticket?

Cheers

Tim Graham

unread,
Jan 31, 2017, 6:12:56 PM1/31/17
to Django users
I've never seen a password as a bytearray. Is there webfaction documentation about this?

ell...@makecollective.co.nz

unread,
Jan 31, 2017, 7:16:41 PM1/31/17
to Django users
Neither.

I haven't seen anything with webfaction and I have used webfaction in the past on several projects and not had any trouble.

Tim Graham

unread,
Jan 31, 2017, 7:21:21 PM1/31/17
to Django users
Oh, I see, you're using bytearray to try to workaround the issue. Well, Django master no longer supports Python 2.7, that's why force_str() was removed. Is there a problem with Django master and Python 3?

ell...@makecollective.co.nz

unread,
Jan 31, 2017, 9:24:13 PM1/31/17
to Django users
Really? I should look at moving to python 3 but my understanding was that python 2.7 would be supported until Django 2.0 according to the docs

Tim Graham

unread,
Feb 1, 2017, 7:12:53 AM2/1/17
to Django users
Following the Django 1.11 alpha release, the stable/1.11.x branch was created and master became Django 2.0 pre-alpha.

You can read more details about how that works at https://docs.djangoproject.com/en/dev/internals/release-process/#release-process

ell...@makecollective.co.nz

unread,
Feb 1, 2017, 2:45:05 PM2/1/17
to Django users
Thanks for getting back to me. 

I guess I have gotten myself confused. Im using 1.10.5 and have been looking at the master version on github. My work around has the emails working so I'll just leave it and get with the times and work with python 3 in the future.
Reply all
Reply to author
Forward
0 new messages