Python smtplib Name or service not known
Question: i was making a simple daemon in python which takes a mail queue and delivers
them to the recipients. Everything is working pretty good except from the
`smtplib` which is actually the most important part.

# What happens?

When im running the script im getting the following error:

    
    
    root@vagrant-ubuntu-trusty-64:/mailer/tests# python daemon_run.py
    [Errno -2] Name or service not known
    

From what i found on the internet this error occurs when it cant connect to
the SMTP server. Most users suggested fixes on postman which i dont use since
i take advantage of google's services.

# The code

    
    
    headers = "\r\n".join(["from: " + "my_email@gmail.com",
                            "subject: " + "Testing",
                            "to: " + "recipient@gmail.com",
                            "mime-version: 1.0",
                            "content-type: text/html"])
    
    content = headers + "\r\n\r\n" + template_content
    
    server = smtplib.SMTP('smtp.google.com', 587)
    server.ehlo()
    server.starttls()
    server.login('my_email@gmail.com', 'pass')
    server.sendmail('my_email@gmail.com', 'recipient@gmail.com', content)
    server.close()
    

Please note that i'm using exactly the same login details in PHPMailer which
actually works.

Any ideas?


Answer: It seems like the goold old typo hit again. Gmail's SMTP is `smtp.gmail.com`
and not `smtp.google.com`

