headers = ['From: ' + sender, 'Subject: ' + subject, 'To: ' + recipient,
    'MIME-Version: 1.0', 'Content-Type: text/html']
headers = '\r\n'.join(headers)
session = smtplib.SMTP(server)
session.sendmail(sender, recipient, headers + '\r\n\r\n' + body)
session.quit()
Sending email from gmail using Python