Hi Sarma On 16 May 2012 11:13, Sarma Tangirala <tvssarma.ome...@gmail.com> wrote:
> Hey guys, > > I was just trying out SMTP and I keep getting a attribute error, > *AttributeError: > 'list' object has no attribute 'lstrip''*, when I use a list to store the > send address. > > Code - http://pastebin.com/9NmCNdRb > > Traceback - http://pastebin.com/m1cgKDnn > > I'm not sure I understand why this is happening. > All the headers in the MimeText object needs to be strings. You can't directly pass a list object containing multiple recipients to the "To" header of your MimeText object on line 31 in your code, and expect it to work. You've got to instead first convert the list to valid string and assign that instead, as that's what the MimeText object expects. You can infer this from your error messages since lstrip() is a string method, and the code is (rightly) complaining that a list doesn't have an lstrip() method, which is understandable becuase you're getting the error when you pass a list as parameter. A quick google yields this question/answer on stackoverflow which is relevant to your question. (See the "cc:" bits): http://stackoverflow.com/questions/5304835/how-to-send-gmail-email-with-multiple-ccs Walter
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor