1

I'm using python and SMTP to send mail

I'm Getting Error in it

My code is

import smtplib

smtp_server = smtplib.SMTP('smtp.gmail.com', 587)
smtp_server.ehlo()
smtp_server.starttls()
smtp_server.login('[email protected]', '587')

smtp_server.sendmail('[email protected]', '[email protected]', 'Subject: Happy Australia Day!\nHi Everyone! Happy  Day! Cheers, Julian')

smtp_server.quit()
print('Email sent successfully')

and Errors are

error: [Error 10061] No connection could be made because the target machine actively refused it

error: [error 10013] An attempt was made to access a socket in a way forbidden by its access permissions

Thanks in advance.

3
  • 1
    Probably firewall is blocking the connection, please check your settings. Commented Aug 30, 2018 at 11:08
  • Please run in terminal telnet smtp.gmail.com 587 and add the output here. Commented Aug 30, 2018 at 11:56
  • I removed setting from firewall and now it works.. Thanks.. Commented Sep 5, 2018 at 4:39

1 Answer 1

2

your firewall blocks the connection. once remove the script would work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.