#!/usr/bin/python
# -*- coding: utf-8 -*-

import os, re
import sys
import smtplib
 
#from email.mime.image import MIMEImage
from email import encoders
from email.mime.base import MIMEBase
from email.MIMEText import MIMEText

SMTP_SERVER = 'smtp.inria.fr'
sender = 'jasmin.blanchette@inria.fr'
login = 'jablanch@inria.fr'
password = "PASSWORD"

#SMTP_SERVER = 'mails.vu.nl'
#sender = 'j.c.blanchette@vu.nl'
#login = 'jbe248@vu.nl'
#password = "PASSWORD"

#SMTP_SERVER = 'smtp.gmail.com'
#sender = 'jasmin.blanchette@gmail.com'
#login = 'jasmin.blanchette@gmail.com'
#password = "PASSWORD"

SMTP_PORT = 587

recipient = sys.argv[1]
subject = ''
 
def main():
    fp = open(sys.argv[3], 'rb')
    msg = MIMEText(fp.read())
    fp.close()
    msg['Subject'] = sys.argv[2]
    msg['To'] = recipient
    msg['From'] = "Jasmin Blanchette <" + sender + ">"
    msg['Reply-To'] = "Jasmin Blanchette <j.c.blanchette@vu.nl>,Johannes Hölzl <jhl890@vu.nl>"
    
    session = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
 
    session.ehlo()
    session.starttls()
    session.ehlo
    
    session.login(login, password)

    # Now send or store the message
    qwertyuiop = msg.as_string()

    session.sendmail(login, recipient, qwertyuiop)
    
    session.quit()
 
if __name__ == '__main__':
    main()
