#84: Put a valid RFC822 mailbox in the FROM: header when sending an email

Just grab the name associated with the sender address.
This commit is contained in:
tonio
2010-11-12 21:54:12 +01:00
parent a85a8f20b0
commit b720b05bf7
+5 -1
View File
@@ -285,8 +285,12 @@ def send_mail(request, withctx=False, origmsg=None, posturl=None):
else:
msg = MIMEText(body.encode(charset), _subtype=subtype)
mb = Mailbox.objects.get(full_address=request.POST["from_"])
msg["Subject"] = request.POST["subject"]
msg["From"] = request.POST["from_"]
if mb is None:
msg["From"] = request.POST["from_"]
else:
msg["From"] = "%s <%s>" % (mb.name, request.POST["from_"])
msg["To"] = request.POST["to"]
msg["Message-ID"] = make_msgid()
msg["User-Agent"] = "Modoboa"