Read the complete article on how to create connection to SMTP server and send emails in Python: https://blog.aspose.com/2022/04/25/connect-to-smtp-server-in-python/
Last active
April 25, 2022 18:02
-
-
Save aspose-com-gists/6352ca6844ca0c4643e38451ecca76c2 to your computer and use it in GitHub Desktop.
Connect to SMTP Server in Python | Send Emails via SMTP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from aspose.email import SmtpClient, SecurityOptions | |
# Create SMTP client | |
client = SmtpClient() | |
# Set properties | |
client.host = "smtp.gmail.com" | |
client.port = 587 | |
client.username = "username" | |
client.password = "password" | |
# Set security options | |
client.security_options = SecurityOptions.SSLEXPLICIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import aspose.email as ae | |
# Create email | |
eml = ae.MailMessage() | |
eml.subject = "Message with Plain Text Body" | |
eml.body = "This is plain text body." | |
eml.from_address = "from@gmail.com" | |
eml.to.append(ae.MailAddress("to@gmail.com", "Recipient 1")) | |
# Configure SMTP Client | |
client = ae.SmtpClient("smtp.gmail.com", 995, "username", "password") | |
client.security_options = ae.SecurityOptions.AUTO | |
# Send email | |
client.send(eml) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment