Issue 1430298: smtplib: empty mail addresses (original) (raw)

It is not possible to send an email with smtplib with an empty return address.

if you leave the sender mail address empty, smtplib will use "" as sender, instead of "<>", as it should do. Note that an empty return address is typically used for mail delivery warnings (it has a valid usage!)

This bug is still in current SVN (I just checked http://svn.python.org/ projects/python/trunk/Lib/smtplib.py). Below is a fix for smtplib.py that came with Python 2.3 (since I still use that version). The bug is in the function "quoteaddr(addr):"

*** orig/smtplib.py 2005-05-14 23:48:03.000000000 +0200 --- smtplib.py 2006-02-08 09:52:25.000000000 +0100


*** 176,181 **** --- 176,183 ---- if m == (None, None): # Indicates parse failure or AttributeError #something weird here.. punt -ddm return "<%s>" % addr