mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
#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:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user