Sending an email in Iron Python taking forever -
so i'm trying send email in iron python 2.7, , nothing has worked me. combined bunch of different bits of code got try , workaround issue. basically, need send zip file without using localhost because i'm assuming client computer won't have localhost.
here code:
# send email def sendemail():      # set standard variables     send_to = ["*******@live.com"]     send_from = "********@outlook.com"     subject   = "new game info"     text      = "some new info you. automated message."      assert isinstance(send_to, list)      msg = mimemultipart(         from=send_from,         to=commaspace.join(send_to),         date=formatdate(localtime=true),         subject=subject     )      print "created mime..."      msg.attach(mimetext(text))      print "attached message..."      open("templog.zip", "rb") fil:         msg.attach(mimeapplication(             fil.read(),             content_disposition='attachment; filename="%s"' % "templog.zip"         ))      print "attached file..."      server = smtplib.smtp()     server.connect("smtp-mail.outlook.com", 587)     server.starttls()     server.login("*********@outlook.com", "*****")     server.sendmail("********@outlook.com", send_to, msg.as_string())     server.close()   so can see, have put print statements everywhere locate issue. gets "attached file...," no further.
i appreciate issue.
i suggest using try/catch block figure out problem is.
with current code:
try:     server = smtplib.smtp()     server.connect("smtp-mail.outlook.com", 587)     server.starttls()     server.login("*********@outlook.com", "*****")     server.sendmail("********@outlook.com", send_to, msg.as_string())     server.close() except smtpexception, err:    print "error: unable send mail - %s" %(err) except exception, err:    print "some other error - %s" %(err)   and example suggest putting host options in smtp initialization instead of doing in connect(). can modify example utilize starttls() need.
try:   smtp = smtplib.smtp(host, port)   smtp.sendmail(sender, receivers, message)            print "successfully sent email '%s'" %(receivers) except smtpexception, err:   print "error: unable send mail - %s" %(err) except exception, err:    print "some other error - %s" %(err)      
Comments
Post a Comment