[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Fwd: Mail delivery failed: returning message to sender



TOMAS MARTIŠIUS <tomas@puga.vdu.lt> writes:

> Thanks for solving this problem, bus I am not expert of all these
> encodings too, so I simply need working reportbug package and I really
> don't know in which point the problem is: in packege or in mailing
> system, which must accept bug report. But if both encodings can be used
> (as says some different RCS's) I prefer to fix mailing system, if it is
> possible, to accept both types of encodings. Especially because bug
> report can be send using some common mail system.

If reportbug generated:

From: =?utf-8?b?VG9tYXMgTWFydGnFoWl1cyA8dG9tYXNAcHVnYS52ZHUubHQ+?=

then this is definitely a bug in reportbug itself.  Looking at the
reportbug source, it is not giving email.message sufficient hints about
how to encode the From header correctly when the name includes non-ASCII
characters, which causes exactly this problem:

| lothlorien:~$ python3
| Python 3.5.2+ (default, Nov 22 2016, 01:00:20) 
| [GCC 6.2.1 20161119] on linux
| Type "help", "copyright", "credits" or "license" for more information.
| >>> from email.mime.text import MIMEText
| >>> message = MIMEText('Some test')
| >>> message['From'] = 'TOMAS MARTIŠIUS <tomas@puga.vdu.lt>'
| >>> message['To'] = 'Russ Allbery <eagle@eyrie.org>'
| >>> print(message)
| Content-Type: text/plain; charset="us-ascii"
| MIME-Version: 1.0
| Content-Transfer-Encoding: 7bit
| From: =?utf-8?b?VE9NQVMgTUFSVEnFoElVUyA8dG9tYXNAcHVnYS52ZHUubHQ+?=
| To: Russ Allbery <eagle@eyrie.org>
| 
| Some test

There are various ways to fix this.  The easiest is probably to use
email.utils.formataddr:

| >>> message = MIMEText('Some test')
| >>> message['From'] = formataddr(('TOMAS MARTIŠIUS', 'tomas@puga.vdu.lt'))
| >>> message['To'] = formataddr(('Russ Allbery', 'eagle@eyrie.org'))
| >>> print(message)
| Content-Type: text/plain; charset="us-ascii"
| MIME-Version: 1.0
| Content-Transfer-Encoding: 7bit
| From: =?utf-8?q?TOMAS_MARTI=C5=A0IUS?= <tomas@puga.vdu.lt>
| To: Russ Allbery <eagle@eyrie.org>
| 
| Some test

I will file a bug against reportbug on your behalf.

-- 
Russ Allbery (rra@debian.org)               <http://www.eyrie.org/~eagle/>


Reply to: