#!/usr/bin/env python
import sys
import smtplib
import argparse
import socket
from ConfigParser import SafeConfigParser
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

socket.setdefaulttimeout(10)

# init arg parser and parse
parser = argparse.ArgumentParser(description='Email-challenge-sender for NDNCERT')
parser.add_argument("email", help="the receiver email address")
parser.add_argument("secret", help="the secret of the challenge")
parser.add_argument("caName", help="the CA name")
args = parser.parse_args()

# open config
confParser = SafeConfigParser()
confParser.read('@SYSCONFDIR@/ndncert/ndncert-mail.conf')

# read smtp settings
encrypt_mode = confParser.get('ndncert_smtp_settings', "ENCRYPT_MODE")
server = confParser.get('ndncert_smtp_settings', 'SMTP_SERVER')
port = confParser.get('ndncert_smtp_settings', 'SMTP_PORT')
username = confParser.get('ndncert_smtp_settings', 'SMTP_USER')
password = confParser.get('ndncert_smtp_settings', 'SMTP_PASSWORD')

# read email settings
msg_from = confParser.get('ndncert_email_settings', 'MAIL_FROM')
subject = confParser.get('ndncert_email_settings', 'SUBJECT')
text = confParser.get('ndncert_email_settings', 'TEXT_TEMPLATE').format(args.secret, args.caName)
html = confParser.get('ndncert_email_settings', 'HTML_TEMPLATE').format(args.secret, args.caName)

# form email message
msg = MIMEMultipart('alternative')
msg.attach(MIMEText(text, 'plain'))
msg.attach(MIMEText(html, 'html'))
msg['From'] = msg_from
msg['To'] = args.email
msg['Subject'] = subject

# send email
if encrypt_mode == 'ssl':
    smtp_server = smtplib.SMTP_SSL(server, port)
else: # none or tls
    smtp_server = smtplib.SMTP(server, port)

if encrypt_mode != 'none':
    smtp_server.ehlo()
    if encrypt_mode == 'tls':
        smtp_server.starttls()

if username != '' and password != '':
    smtp_server.login(username, password)

smtp_server.sendmail(msg_from, args.email, msg.as_string())
smtp_server.close()
sys.exit()
