--- mga-gnome/trunk/mga-gnome 2012/03/02 21:25:11 3180 +++ mga-gnome/trunk/mga-gnome 2012/03/11 13:15:23 3384 @@ -628,7 +628,16 @@ """Send an reply email""" contents.seek(0) msg = MIMEText(contents.read(), _charset='utf-8') - msg['Subject'] = "Re: %s%s" % (orig_msg['Subject'], " (ERROR)" if error else "") + if error: + # XXX - ugly + contents.seek(0) + lastline = contents.read().splitlines()[-1] + # Remove things like "ERROR: " and so on from the last line + lastline = re.sub(r'^(?:[^ :]+:\s+)+', '', lastline) + subjecterrror = " (ERROR: %s)" % lastline if lastline else " (ERROR)" + else: + subjecterror = "" + msg['Subject'] = "Re: %s%s" (orig_msg['Subject'], subjecterror) msg['To'] = to msg["In-Reply-To"] = orig_msg["Message-ID"] msg["References"] = orig_msg["Message-ID"]