How to automate using Python

We can automate almost everything with Python. This includes sending emails and filling out PDFs and CSVs to interacting with external APIs and sending HTTP requests.
For simple automation, Python’s built-in libraries should be enough.
In this article, let’s see how to use automation for sending emails with Python.
Python comes bundled with the smtplib
library, which you can use to send emails via the Simple Mail Transfer Protocol (SMTP).
import getpass import smtplib host="smtplib.gmail.com" port=465 username="yourmail@gmail.com" password=getpass.getpass("gmail password: ") server=smtplib.SMTP_SSL(host, port) server.login(username, password) (235, b'2.7.0 Accepted') server.sendmail( 'from@domain.com', 'to@domain.com', 'An email from Python!', ) {} server.quit() (221, b'2.0.0 closing connection s1sm24313728ljc.3 - gsmtp')
Subscribe
Login
Please login to comment
0 Discussion