1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Sending rich HTML emails with Python

Discussion in 'HTML, Graphics & Programming' started by Goldy, May 9, 2018.

  1. Goldy

    Wise Guy

    Joined: Mar 30, 2004

    Posts: 1,147

    Location: West Wing

    Whats the best way of sending HTML emails from Python 2.7? I have a script that uses smptlib library to send plain text emails from a gmail account. But I want to send the content as HTML with images.

    Is there a third party API service or another Python library anyone can recommend?
  2. AHarvey


    Joined: Mar 6, 2008

    Posts: 8,929

    Location: Stoke area

  3. iKettles

    Wise Guy

    Joined: Sep 26, 2007

    Posts: 1,243

    Location: Amsterdam

    I wouldn't bother yourself with the pain of setting up SMTP yourself, there's lots of things you'll miss which managed email services handle for you. Check out https://sendgrid.com/, they have a pretty generous free package and a nice python client library: https://github.com/sendgrid/sendgrid-python. They also have their own templating system if you don't want to deal with that on the python side.