notification.py
def send(self, to_addrs: str, subject: str, body: str):
        """Sends a message to me as Alice."""
        msg = MIMEMultipart()
        msg['From'] = BOT_GMAIL_ADDRESS
        msg['To'] = to_addrs
        msg['Subject'] = subject
        msg.attach(MIMEText(body))

        # Message through SMS Gateway is not properly encoded unless there are 2 or more MIME parts.
        msg.attach(MIMEText(''))

        with smtplib.SMTP('smtp.gmail.com') as connection:
            connection.starttls()
            connection.login(user=BOT_GMAIL_ADDRESS,
                             password=BOT_GMAIL_PASSWORD)
            connection.sendmail(from_addr=BOT_GMAIL_ADDRESS,
                                to_addrs=to_addrs,
                                msg=msg.as_string())
Sends a message to me as Alice.
Sends a message to me as Alice.
Sends a message to me as Alice .
def send(self, to_addrs: str, subject: str, body: str):
        msg = MIMEMultipart()
        msg['From'] = BOT_GMAIL_ADDRESS
        msg['To'] = to_addrs
        msg['Subject'] = subject
        msg.attach(MIMEText(body))
        msg.attach(MIMEText(''))
        with smtplib.SMTP('smtp.gmail.com') as connection:
            connection.starttls()
            connection.login(user=BOT_GMAIL_ADDRESS,
                             password=BOT_GMAIL_PASSWORD)
            connection.sendmail(from_addr=BOT_GMAIL_ADDRESS,
                                to_addrs=to_addrs,
                                msg=msg.as_string())
def send ( self , to_addrs : str , subject : str , body : str ) : msg = MIMEMultipart ( ) msg [ 'From' ] = BOT_GMAIL_ADDRESS msg [ 'To' ] = to_addrs msg [ 'Subject' ] = subject msg . attach ( MIMEText ( body ) ) msg . attach ( MIMEText ( '' ) ) with smtplib . SMTP ( 'smtp.gmail.com' ) as connection : connection . starttls ( ) connection . login ( user = BOT_GMAIL_ADDRESS , password = BOT_GMAIL_PASSWORD ) connection . sendmail ( from_addr = BOT_GMAIL_ADDRESS , to_addrs = to_addrs , msg = msg . as_string ( ) )
Sends a message to me as Alice.
Sends a message to me as Alice .
"""Sends a message to me as Alice.""" # Message through SMS Gateway is not properly encoded unless there are 2 or more MIME parts.
self
to_addrs
str
subject
str
body
str