actually the bug was in the previous version. You have to specify the
encoding
return mail.send(to=
['[email protected]','[email protected]'],
subject=about,
message=msg, encoding='latin1')
On Dec 8, 7:05 pm, blackthorne <[email protected]> wrote:
> hi
> there seems to be a bug a in the unicode process, probably in the mail
> () method on the most recent versions of web2py. I developed an
> application with a contact form that works on. When I got it into
> production, I tested it with the latest version of web2py and I got
> Internal Server Error with the message:
>
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
> 0: ordinal not in range(128)
>
> def email_user(sender,msg,about="group notice"):
> message='Reply-to: ' + sender + '\n ' + msg
> return mail.send(to=
> ['[email protected]','[email protected]'],
> subject=about,
> message=msg)
>
> def contact():
> response.view = theme + '/contact.html'
> form=SQLFORM(db.mail,fields=
> ['your_name','your_email','your_message'])
> if form.accepts(request.vars,session,dbio=False):
> subject='casasdocastro.com: ' + form.vars.your_name
> sent = email_user(sender=form.vars.your_email,
> --> msg=form.vars.your_message,
> about=subject)
> if sent:
> response.flash=T('message_submitted')
> else:
> response.flash=T('message_failed')
> db.mail.insert(your_name=form.vars.your_name,
> your_email=form.vars.your_email, your_message=form.vars.your_message,
> sent=sent)
> elif form.errors:
> response.flash=T('check_contact_form')
> form.custom.submit['_value']=T('send_submit')
> return dict(form=form,
> news=getNews())
>
> Again, this code works fine in v1.67
>
> Thank, Best Regards
--
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en.