def sendMail(config, To_mail, msgBody, PDFfile):
    senderEmail = config.get("from_mail","")
    mailserver = config.get("email_server","")
    mailserveruser = config.get("email_login","")          # <-- set to None if no login required
    mailserverpasswd = config.get("email_password","")     # <-- set to None if no login required

    # create the mail message
    msg = MIMEMultipart(_subtype='html')
    msg['Subject'] = 'Auto-generated eMail from SuperSID'
    msg.attach( MIMEText(msgBody) )

    # Following headers are useful to show the email correctly
    msg['From'] = senderEmail
    msg['Reply-to'] = senderEmail
    msg['To'] = To_mail
    msg['Date'] = utils.formatdate(localtime = 1)

    # attach the PDF file
    ctype, encoding = ('application/pdf', None)
    maintype, subtype = ctype.split('/', 1)
    with open(PDFfile, 'rb') as pdf:
        att = MIMEBase(maintype, subtype)
        att.set_payload(pdf.read())
        encoders.encode_base64(att)
        att.add_header('Content-Disposition', 'attachment', filename=PDFfile)
        msg.attach(att)

    # Establish an SMTP object by connecting to your mail server
    s = smtplib.SMTP()
    s.connect(mailserver)
    if mailserveruser: s.login(mailserveruser, mailserverpasswd)
    # Send the email - real from, real to, extra headers and content ...
    s.sendmail(senderEmail, To_mail, msg.as_string())
    s.close()
    print("Email to %s sent." % To_mail)
Estimate mutual information for a discrete target variable.
dataset/ETHPy150Open ericgibert/supersid/supersid/supersid_plot.py/sendMail--crossover with--dataset/ETHPy150Open scikit-learn/scikit-learn/sklearn/feature_selection/mutual_info_.py/mutual_info_classif