Send
    ➜  ~ cat /opt/scripts/mail.py
    !/usr/bin/env python3
    import os
    import sys
    import smtplib
    import mimetypes
    from email.mime.multipart import MIMEMultipart
    from email.mime.base import MIMEBase
    from email.mime.text import MIMEText
    from email.mime.audio import MIMEAudio
    from email.mime.image import MIMEImage
    from email import encoders
    
    def sendMail(subject, text):
        gmailUser = 'pve@t.ch'
        gmailPassword = 'pa55Word'
        recipient = 'pve@t.ch'
    
         Create the container email message
        msg = MIMEMultipart()
        msg['From'] = gmailUser
        msg['To'] = recipient
        msg['Subject'] = subject
        msg.attach(MIMEText(text, 'plain'))
    
        try:
             Setup the SMTP server
            mailServer = smtplib.SMTP('xxxx.xxx', 1234)
            #mailServer.ehlo()
            #mailServer.starttls()
            #mailServer.ehlo()
            mailServer.login(gmailUser, gmailPassword)
    
             Send the email
            mailServer.sendmail(gmailUser, recipient, msg.as_string())
            mailServer.close()
    
            print('Sent email to %s' % recipient)
        except Exception as e:
            print('Failed to send email: %s' % str(e))
    
    if __name__ == "__main__":
        if len(sys.argv) != 3:
            print("Usage: send_mail.py <subject> <message>")
            sys.exit(1)
    
        subject = sys.argv[1]
        text = sys.argv[2]
        sendMail(subject, text)