"""Send e-mail notification to system administrators.""" import email import smtplib import socket import subprocess def notify(subject, whom, what): """Send email notification. Try to notify the addressee (``whom``) by e-mail, with Subject: defined by ``subject`` and message body by ``what``. """ msg = email.message_from_string(what) msg.add_header("From", "Certbot renewal agent <root>") msg.add_header("To", whom) msg.add_header("Subject", subject) msg = msg.as_string() try: lmtp = smtplib.LMTP() lmtp.connect() lmtp.sendmail("root", [whom], msg) except (smtplib.SMTPHeloError, smtplib.SMTPRecipientsRefused, smtplib.SMTPSenderRefused, smtplib.SMTPDataError, socket.error): # We should try using /usr/sbin/sendmail in this case try: proc = subprocess.Popen(["/usr/sbin/sendmail", "-t"], stdin=subprocess.PIPE) proc.communicate(msg) except OSError: return False return True
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
__pycache__ | Folder | 0755 |
|
|
compat | Folder | 0755 |
|
|
display | Folder | 0755 |
|
|
plugins | Folder | 0755 |
|
|
tests | Folder | 0755 |
|
|
__init__.py | File | 114 B | 0644 |
|
account.py | File | 13.63 KB | 0644 |
|
achallenges.py | File | 1.59 KB | 0644 |
|
auth_handler.py | File | 18.42 KB | 0644 |
|
cert_manager.py | File | 15.01 KB | 0644 |
|
cli.py | File | 70.83 KB | 0644 |
|
client.py | File | 29.65 KB | 0644 |
|
configuration.py | File | 5.67 KB | 0644 |
|
constants.py | File | 6.6 KB | 0644 |
|
crypto_util.py | File | 15.85 KB | 0644 |
|
eff.py | File | 3.06 KB | 0644 |
|
error_handler.py | File | 6.92 KB | 0644 |
|
errors.py | File | 2.59 KB | 0644 |
|
hooks.py | File | 8.84 KB | 0644 |
|
interfaces.py | File | 21.53 KB | 0644 |
|
lock.py | File | 9.55 KB | 0644 |
|
log.py | File | 12.43 KB | 0644 |
|
main.py | File | 48.82 KB | 0644 |
|
notify.py | File | 1.04 KB | 0644 |
|
ocsp.py | File | 12.83 KB | 0644 |
|
renewal.py | File | 20.89 KB | 0644 |
|
reporter.py | File | 3.46 KB | 0644 |
|
reverter.py | File | 23.97 KB | 0644 |
|
ssl-dhparams.pem | File | 424 B | 0644 |
|
storage.py | File | 44.99 KB | 0644 |
|
updater.py | File | 3.86 KB | 0644 |
|
util.py | File | 19.09 KB | 0644 |
|