I'm trying send an attachment with an e-mail using following code. But it gives an error. Without the attachment it works perfectly. What is the problem with this code?
"mail5.py", line 14 smtpObj = smtplib.SMTP('domain', 25) ^ SyntaxError: invalid syntax #!/usr/bin/python import smtplib sender = '[email protected]' receivers = ['[email protected]'] from email.MIMEMultipart import MIMEMultipart from email.MIMEText import MIMEText from email.MIMEImage import MIMEImage msg = MIMEMultipart() msg.attach(MIMEText(file("text.txt").read()) smtpObj = smtplib.SMTP('domain', 25) smtpObj.sendmail(sender, receivers, msg.as_string()) print "Successfully sent email"