After a successful execution of a bash-script I need to send a mail to other domain, without a mail configure in the sender machine.
If it possible to execute a python script inside a bash-script for sending mail with bash variables?
Or any other way to share the same variables from a shell-script to a python script?
I found a python script for sending mail,
#!/usr/bin/python
from smtplib import SMTP
import datetime
debuglevel = 0
smtp = SMTP()
smtp.set_debuglevel(debuglevel)
smtp.connect('192.168.75.1', 25)
smtp.login('my_mail', 'mail_passwd')
from_addr = "My Name <my_mail@192.168.75.1>"
to_addr = "<my_mail@192.168.75.1"
subj = "Process completed"
date = datetime.datetime.now().strftime( "%d/%m/%Y %H:%M" )
#print (date)
message_text = "Hai..\n\nThe process completed."
msg = "From: %s\nTo: %s\nSubject: %s\nDate: %s\n\n%s" % ( from_addr, to_addr, subj, date, message_text )
smtp.sendmail(from_addr, to_addr, msg)
smtp.quit()
But I need to execute this on the same script, because the bash-script parameters must be the body of the mail.