fromaddr = 'sending@example.com'
toaddrs = ['receiving@gmail.com']
msg = """
    From: {fromaddr}
    To: {toaddr}
    Subject: testin'     
    This is a test 
    .
"""
msg = msg.format(fromaddr=fromaddr, toaddr=toaddrs[0])
server = smtplib.SMTP('gmail-smtp-in.l.google.com:25')
server.starttls()
server.ehlo('example.com')
server.mail(fromaddr)
server.rcpt(toaddrs[0])
server.data(msg)
server.quit()
How to send a mail directly to SMTP server without authentication?