def mail_article(article, dir, mailfrom, extension):
    "mail an article to a friend"
    a = add_fileextension(article, extension)
    a = os.path.join(dir, a)

    # Create a text/plain message
    try:
        fp = open(a, 'r')
        msg = MIMEText(fp.read())
        fp.close()
    except __HOLE__:
        print("Error: Please specify a document")
        return False


    mailto = raw_input("Recipient: ")
    msg['Subject'] = article
    msg['From'] = mailfrom
    msg['To'] = mailto

    # Send the message via our own SMTP server, but don't include the
    # envelope header.
    s = smtplib.SMTP()
    try:
        s.connect()
        s.sendmail(mailfrom, [mailto], msg.as_string())
        s.quit()
    except socket.error:
        print("Error: Apparently no mailer running on your system.")
        print("Error: Could not connect to localhost:25")
        return False
    except smtplib.SMTPRecipientsRefused:
        print("Error: Invalid recipient or sender")
        return False
dataset/ETHPy150Open noqqe/cmddocs/cmddocs/articles.py/mail_article