smtplib - Python - sending an email through gmail servers -


when type following code idle works fine:

>>> import smtplib >>> smtpobj = smtplib.smtp('smtp.gmail.com', 587) >>> smtpobj.ehlo() >>> smtpobj.starttls() >>> smtpobj.login("email", "password") >>> smtpobj.sendmail("email", "email2", "subject: test \nsent python!") >>> smtpobj.quit() 

but when try make program out of make easier emailing gives me syntax error (error 2 * on each side of it):

import smtplib  smtpobj = smtplib.smtp('smtp.gmail.com', 587) smtpobj.ehlo() smtpobj.starttls()  email = input("what email?: ") password = input("what password?: ")  **smtpobj**.login(email, password)  print ("from: " + email) = input("to: ") subject = input("subject: ") message = input("message: \n")  smtpobj.sendmail(email, to, subject + message)  print ("email sent successfuly!!!")  smtpobj.quit() 

if on python 2, use raw_input instead input.

according official docs:

input([prompt])

equivalent eval(raw_input(prompt)).

this function not catch user errors. if input not syntactically valid, syntaxerror raised. other exceptions may raised if there error during evaluation.

in python 3 there input

anyway, not close parenthesis in input's 'password'


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -