我正在尝试使用以下代码通过电子邮件发送附件。但它给出了一个错误。没有附件,它可以完美运行。这段代码有什么问题?
"mail5.py", line 14
smtpObj = smtplib.SMTP('domain', 25)
^
SyntaxError: invalid syntax
#!/usr/bin/python
import smtplib
sender = 'a@a.com'
receivers = ['b@b.com']
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"