sendmail error

sandric ionut sandricionut at yahoo.com
Tue Aug 31 10:25:50 CEST 2010



Hello:

I have a script for sending email from python (it is attached bellow). When I am 
launching the script I get the error:
TypeError: cannot concatenate 'str' and 'type' objects if I use sys.argv[1], but 
if I input from the begging an email address like "email at email.com", the script 
is working OK

What could be the problem?

Thank you,

Ionut

import
mesaj = email.MIMEMultipart.MIMEMultipart()
fromEmail = sys.argv[
toEmail = os, sys, smtplib, email1]"toEmail"mesaj[
mesaj[
mesaj["From"] = fromEmail"To"] = toEmail"Subject"] = "Teste"mesaj[
atasament = r"Date"] = 
email.Utils.formatdate(localtime=True)"d:\Doc1.zip"atasamentP = 
email.MIMEBase.MIMEBase(
atasamentP.set_payload(open(atasament,
email.Encoders.encode_base64(atasamentP)
atasamentP.add_header(
mesaj.attach(atasamentP)
mesaj.attach(email.MIMEText.MIMEText(
smtpObj = 
smtplib.SMTP('application','zip')"rb").read())'Content-Disposition','attachement;
 filename="%s"'% os.path.basename(atasament))"Email transmis la data: ", 
email.Utils.formatdate(localtime=False)))"192.168.1.2")try
smtpObj.sendmail(fromEmail, toEmail, mesaj.as_string())
smtpObj.close():exceptsmtplib.SMTPException:print"eroare: "+ 
smtplib.SMTPException


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100831/d39b2fa8/attachment.html>


More information about the Python-list mailing list