
Y[c           @   sC   d  Z  d d l Z d d l Z d d l Z d d l Z d   Z d S(   s2   Send e-mail notification to system administrators.iNc      	   C   s   t  j |  } | j d d  | j d |  | j d |   | j   } y0 t j   } | j   | j d | g |  Wns t j t j	 t j
 t j t j f k
 r y/ t j d d g d t j } | j |  Wq t k
 r t SXn Xt S(	   s   Send email notification.

    Try to notify the addressee (``whom``) by e-mail, with Subject:
    defined by ``subject`` and message body by ``what``.

    t   Froms   Certbot renewal agent <root>t   Tot   Subjectt   roots   /usr/sbin/sendmails   -tt   stdin(   t   emailt   message_from_stringt
   add_headert	   as_stringt   smtplibt   LMTPt   connectt   sendmailt   SMTPHeloErrort   SMTPRecipientsRefusedt   SMTPSenderRefusedt   SMTPDataErrort   sockett   errort
   subprocesst   Popent   PIPEt   communicatet   OSErrort   Falset   True(   t   subjectt   whomt   whatt   msgt   lmtpt   proc(    (    s2   /usr/lib/python2.7/dist-packages/certbot/notify.pyt   notify	   s$    
	(   t   __doc__R   R	   R   R   R    (    (    (    s2   /usr/lib/python2.7/dist-packages/certbot/notify.pyt   <module>   s
   