import smtplib
import sys
from email.message import EmailMessage
import ci_secrets


def run(body):
    msg = EmailMessage()
    msg['Subject'] = "CoopdevCI : script error"
    msg['From'] = "brevo@ksuite-coopdev.fr"
    msg['To'] = "yvon.kerdoncuff@gmail.com"
    msg.set_content(body)

    s = smtplib.SMTP('smtp-relay.sendinblue.com', port=587)
    s.login("brevo@ksuite-coopdev.fr", ci_secrets.mail_server_password)
    s.send_message(msg)
    s.quit()


if __name__ == '__main__':
    arg = ""
    if len(sys.argv) > 1:
        arg = sys.argv[1]
    run(arg)