#! /usr/bin/python2.7

import sys
from email.mime.text import MIMEText
from email.MIMEBase import MIMEBase
from email.MIMEMultipart import MIMEMultipart
from email.Encoders import encode_base64
from smtplib import SMTP, SMTP_SSL


from_address = "vfax@zargotel.eu"  
from_address_password = "v1ct0r1aoo85jj"
from_port = 465
to_address = sys.argv[2]
message =  "<em>Adjunto </em>, <strong>CDR</strong>!"

mime_message=MIMEMultipart()
mime_message["From"] = from_address
mime_message["To"] = to_address
mime_message["Subject"] = sys.argv[3] 

#adjunto
file=sys.argv[1] 
adjunto = MIMEBase('application', "octet-stream")
adjunto.set_payload(open(file, "rb").read())
encode_base64(adjunto)
adjunto.add_header('Content-Disposition', 'attachment; filename = "%s"' % file)
mime_message.attach(MIMEText(message, 'html'))
mime_message.attach(adjunto)

#message = "<em>Adjunto</em>, <strong>fax</strong>!"
#mime_message = MIMEText(message, "html", _charset="utf-8")

smtp = SMTP_SSL("mail.zargotel.eu", from_port)
smtp.login(from_address, from_address_password)
smtp.sendmail(from_address, to_address, mime_message.as_string())
smtp.quit()


