I have the next function:
hostname = os.uname()[1]
def sendmail(sender, receiver, content, user=None, password=None, hostname='localhost', port=25,ssl=False):
smt_server = 'localhost'
port = '25'
sender = 'jenkins@jenkins.com'
receiver = 'test@test.es'
content = "I need to show hostname here" , hostname , "Done."
msg = MIMEText(content)
msg['From'] = sender
msg['To'] = receiver
msg['Subject'] = 'Simple app script'
try:
s = smtplib.SMTP('localhost', port )
s.sendmail('jenkins@jenkins.com', 'test@test.es', content)
s.quit()
print "Succesfully sent email"
except SMTPException:
print "Error: fail to send email"
Actual result:
AttributeError: 'tuple' object has no attribute 'encode'
Expected result:
The body message of the mail have to be:
I need to show hostname here MyHostname Done.
I'm not sure if i'm using the rigth way, could you help me?
Thanks