Sending Emails using python 2 ERROR

I'm going to make this short so basically,
I'm trying to send an email with text that says something.
the following code it what I'm using:
      import smtplib

gmail_user = 'name@gmail.com' 
gmail_password = 'password'

sent_from = gmail_user 
to = 'me@gmail.com' 
subject = 'OMG Super Important Message' 
body = 'blah blah blah this is a message'

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...'
so where it says 'body' I can put like a variable not just a text and it would send. But now,
when I send a program to someone and they go through the steps until this script and it wont work, what I get in my email is "Sign-in attempt was blocked" and I wont get the data I need. How can I fix this?

Комментарии

Популярные сообщения из этого блога

Как преобразовать вертикальную запись в горизонтальную?

Skipping acquire of configured file 'contrib/binary-i386/Packages' as repository … doesn't support architecture 'i386'

How to delete a folder in remote Windows from Linux