| 1584 | smtpserver.quit() |
| 1585 | |
| 1586 | def default_email_sender(self, message_text): |
| 1587 | try: |
| 1588 | from . import webapi |
| 1589 | except ImportError: |
| 1590 | webapi = Storage(config=Storage()) |
| 1591 | |
| 1592 | sendmail = webapi.config.get("sendmail_path", "/usr/sbin/sendmail") |
| 1593 | |
| 1594 | assert not self.from_address.startswith("-"), "security" |
| 1595 | |
| 1596 | for r in self.recipients: |
| 1597 | assert not r.startswith("-"), "security" |
| 1598 | |
| 1599 | cmd = [sendmail, "-f", self.from_address] + self.recipients |
| 1600 | |
| 1601 | p = subprocess.Popen(cmd, stdin=subprocess.PIPE) |
| 1602 | p.stdin.write(message_text.encode("utf-8")) |
| 1603 | p.stdin.close() |
| 1604 | p.wait() |
| 1605 | |
| 1606 | def __repr__(self): |
| 1607 | return "<EmailMessage>" |