Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

to send gmail in python

import smtplib

gmail_user = 'yourgoogleaccountname'
gmail_password = 'yourgoogleaccountpassword'

sent_from = gmail_user
to = ['him@gmail.com', 'kill@gmail.com']
subject = 'OMG Super Important Message'
body = 'Hey, what's up guys'

email_text = """
From: %s
To: %s
Subject: %s

%s
""" % (sent_from, ", ".join(to), subject, body)

try:
    server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
    server.ehlo()
    server.login(gmail_user, gmail_password)
    server.sendmail(sent_from, to, email_text)
    server.close()

    print('Email sent!')
except:
    print('Something went wrong...')
Comment

PREVIOUS NEXT
Code Example
Python :: python turtle get mouse position 
Python :: feature importance plot 
Python :: python remove empty lines from file 
Python :: python printing variables 
Python :: read binary image python 
Python :: Converting uint8 into integers 
Python :: python list unique in order 
Python :: python code to convert celsius to fahrenheit 
Python :: contains duplicate in python 
Python :: django error table already exists 
Python :: Python all versions lookup 
Python :: valor absoluto en python 
Python :: pandas change date format to yyyy-mm-dd 
Python :: does jupyter notebook need internet 
Python :: delete dictionary key python 
Python :: python cross validation 
Python :: detect operating system using python 
Python :: multiclass ROC AUC curve 
Python :: plot using matplotlib 
Python :: softmax function python 
Python :: How to load .mat file and convert it to .csv file? 
Python :: generate unique id from given string python 
Python :: how to edit messages in discord . py 
Python :: python float to decimal 
Python :: Using python permutations function on a list 
Python :: python parallel processing for loop 
Python :: flask python use specified port 
Python :: python find directory of file 
Python :: python remove space from end of string 
Python :: python define an array of dictonary 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =