Python Helps Me!!!
I searched and searched and finally I found python. :D
Thanks to all online tutorials and blog that shared how to send mail using python script. I cannot list them because I don’t remember all and I read many many website. :) sorry for that.
I just write script file that accept parameters. And then from my program I call python and execute that script file given parameters. :) that all!!! How easy!!! I should have know early. :D
here is my script: (correct me if my code is wrong or missing something, so far it works fine)
filename = sys.argv
fo = open(filename,"rb")
filecontent = fo.read()
encodedcontent = base64.b64encode(filecontent)
FROM = sys.argv
TO = sys.argv
marker = "AUNIQUEMARKER"
body = sys.argv
part1 = """From: %s
Content-Type: multipart/mixed; boundary=%s
""" % (FROM,TO, sys.argv,marker, marker)
""" % (body,marker)
part3 = """Content-Type: multipart/mixed; name=\"%s\"
""" % (filename,filename,encodedcontent,marker)
message = part1 + part2 + part3
This script take 9 parameters; as I called python to run this script, it becomes all together 10 parameters. This script itself is parameter. This script accept attachment as my program needs it.
here is how to execute from my program.
self.execute("/usr/bin/python",[script_file, sender, receivers, body, subject, smtp_host, smtp_port, smtp_username, password, attach_file]);
Of course, self.execute is customized function. :)
That’s all for today. Oh By the way, happy birthday to me. :D LOL.