Add SMTP delivery labels
- SMTP delivery now has from and to labels for local addresses
This commit is contained in:
parent
b8a08a0ce9
commit
8e066eaa97
|
@ -1,4 +1,5 @@
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
|
from email.header import Header
|
||||||
import smtplib
|
import smtplib
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
|
@ -54,9 +55,13 @@ class smtpDeliver(threading.Thread, StoppableThread):
|
||||||
to = urlparse.parse_qs(u.query)['to']
|
to = urlparse.parse_qs(u.query)['to']
|
||||||
client = smtplib.SMTP(u.hostname, u.port)
|
client = smtplib.SMTP(u.hostname, u.port)
|
||||||
msg = MIMEText(body, 'plain', 'utf-8')
|
msg = MIMEText(body, 'plain', 'utf-8')
|
||||||
msg['Subject'] = subject
|
msg['Subject'] = Header(subject, 'utf-8')
|
||||||
msg['From'] = fromAddress + '@' + SMTPDOMAIN
|
msg['From'] = fromAddress + '@' + SMTPDOMAIN
|
||||||
msg['To'] = toAddress + '@' + SMTPDOMAIN
|
toLabel = map (lambda y: shared.safeConfigGet(y, "label"), filter(lambda x: x == toAddress, shared.config.sections()))
|
||||||
|
if len(toLabel) > 0:
|
||||||
|
msg['To'] = "\"%s\" <%s>" % (Header(toLabel[0], 'utf-8'), toAddress + '@' + SMTPDOMAIN)
|
||||||
|
else:
|
||||||
|
msg['To'] = toAddress + '@' + SMTPDOMAIN
|
||||||
client.ehlo()
|
client.ehlo()
|
||||||
client.starttls()
|
client.starttls()
|
||||||
client.ehlo()
|
client.ehlo()
|
||||||
|
|
Reference in New Issue
Block a user