Search code examples
python-2.7gmail

Python - Sending email with attachment using GMAIL smtp gives error


I'm trying to send an email using Python and Google's smtp. After calling it I get an error:

   msg = MIMEMultipart('alternative')
TypeError: 'LazyImporter' object is not callable

Did anyone had the same problem ? What's the solution for that ?

My code:

Pastebin code


Solution

  • Just change your imports to

    from email.mime.multipart import MIMEMultipart
    from email.mime.text import MIMEText
    from email.mime.base import MIMEBase