I have python code designed to send email with an attachment, and I got to this:
And I get this error on startup:
Traceback (most recent call last): File "./abcd.py", line 49, in <module> main() File "./abcd.py", line 44, in main session.sendmail(sender, recipient, qwertyuiop.as_string()) File "/usr/lib/python2.7/email/message.py", line 137, in as_string g.flatten(self, unixfrom=unixfrom) File "/usr/lib/python2.7/email/generator.py", line 83, in flatten self._write(msg) File "/usr/lib/python2.7/email/generator.py", line 108, in _write self._dispatch(msg) File "/usr/lib/python2.7/email/generator.py", line 134, in _dispatch meth(msg) File "/usr/lib/python2.7/email/generator.py", line 203, in _handle_multipart g.flatten(part, unixfrom=False) File "/usr/lib/python2.7/email/generator.py", line 83, in flatten self._write(msg) File "/usr/lib/python2.7/email/generator.py", line 108, in _write self._dispatch(msg) File "/usr/lib/python2.7/email/generator.py", line 125, in _dispatch main = msg.get_content_maintype() AttributeError: 'str' object has no attribute 'get_content_maintype'
I assume this is related to msg.attach ("/tmp/images/a.gif"), but I'm not sure. The source of the problem is qwertyuiop.as_string (), though.
source share