0

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" 
1
  • 1
    msg.attach(MIMEText(file("text.txt").read()) <-- missed parenthesis here. Commented May 2, 2013 at 5:06

1 Answer 1

2

It looks like you're missing a closing parenthesis on the preceding line, try this:

msg.attach(MIMEText(file("text.txt").read())) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.