Email From-Header line is missing quotes

Bug #1187464 reported by Karsten Becker
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Confirmed
Wishlist
OpenERP's Framework R&D

Bug Description

In Settings -> Users -> Peter Pan you change the name to 'Pan, Peter' (without the quotes).

Then send an email to an external email address.

We use Postfix. Postfix gets presented by a FROM line in the email header which looks like:
From: Pan, Peter <email address hidden>

which is wrong - it has to be
From: "Pan, Peter" <email address hidden>

at least in this special case, if the name contains a comma.

Without the double quotes, Postfix reads two sender addresses, 'Pan' and 'Peter <email address hidden>', separated by a comma. 'Pan' gets rewritten to a standard form according to
> http://www.postfix.org/ADDRESS_REWRITING_README.html#standard

for example to '<email address hidden>'. Then the mail server delivers the email to the recipient (or applies additional rewritings with sender_canonical afterwards to get rid of the server name and replace it with a domain, which makes it more confusing).

The recipient gets an email containing two senders, unfortunately the first one is visible in his client (tested with Gmail Web Client and Thunderbird).

Regards
Karsten

Revision history for this message
Karsten Becker (karstenrbecker) wrote :

Version: 7.0 nightly, downloaded from www.openerp.com
Package: Ubuntu DEB
Postfix: 2.7.0
Ubuntu: 12.04 LTS, fully patched

affects: openobject-addons → openerp-web
affects: openerp-web → openobject-server
Amit Parik (amit-parik)
Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Carlos Vásquez (ClearCorp) (cv.clearcorp) wrote :

Some more thoughts about this.

The best practice here is not wrapping the sender or recipient name in double quotes, the best option is to encode in RFC2822 every time, even if there are only ASCII characters. This is because, the most used standard is that senders or recipients names should not even have spaces.

Try the same example as described by Karsten, but include an UTF8 character in the user name. For example, with "Pan, Pëter". You will see that the problem is gone, same for the recipients.

The easy way to do this, is to allow double quotes in the email_from, email_to, email_cc and email_bcc fields of the build_email method of the ir_mail_server class (openerp/base/ir/ir_mail_server.py). As of now, if any double quotes are passed along to this method (form the mail module for example), the build_email method encodes the name with the quotes included, resulting in an email received form "Pan, Pëter" (the quotes showing in your email client around the name). This is because the quotes get encoded along with the rest because a non ASCII character is found.

So this can be solved by always encoding sender and recipient names, but without encoding the quotes. For this, you must fix the encode_rfc2822_address_header method (the same file) so it can receive the quotes, but without encoding them in the result.

Summarizing, this is the approach that big email providers use (like Gmail). Always encode names in sender and recipients, never use quotes in final messages, if quotes are received, replace them by enconding.

I don't have time right now to change the code myself but I can help to test or share any more thoughts with you if you need me to.

Regards

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.