MCPcopy Index your code
hub / github.com/webpy/webpy / __init__

Method __init__

web/utils.py:1444–1478  ·  view source on GitHub ↗
(self, from_address, to_address, subject, message, headers=None, **kw)

Source from the content-addressed store, hash-verified

1442
1443class _EmailMessage:
1444 def __init__(self, from_address, to_address, subject, message, headers=None, **kw):
1445 def listify(x):
1446 if not isinstance(x, list):
1447 return [safestr(x)]
1448 else:
1449 return [safestr(a) for a in x]
1450
1451 subject = safestr(subject)
1452 message = safestr(message)
1453
1454 from_address = safestr(from_address)
1455 to_address = listify(to_address)
1456 cc = listify(kw.get("cc", []))
1457 bcc = listify(kw.get("bcc", []))
1458 recipients = to_address + cc + bcc
1459
1460 import email.utils
1461
1462 self.from_address = email.utils.parseaddr(from_address)[1]
1463 self.recipients = [email.utils.parseaddr(r)[1] for r in recipients]
1464
1465 self.headers = dictadd(
1466 {"From": from_address, "To": ", ".join(to_address), "Subject": subject},
1467 headers or {},
1468 )
1469
1470 if cc:
1471 self.headers["Cc"] = ", ".join(cc)
1472
1473 self.message = self.new_message()
1474 self.message.add_header("Content-Transfer-Encoding", "7bit")
1475 self.message.add_header("Content-Disposition", "inline")
1476 self.message.add_header("MIME-Version", "1.0")
1477 self.message.set_payload(message, "utf-8")
1478 self.multipart = False
1479
1480 def new_message(self):
1481 from email.message import Message

Callers

nothing calls this directly

Calls 5

new_messageMethod · 0.95
safestrFunction · 0.85
dictaddFunction · 0.85
joinMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected