Last active
November 7, 2020 04:52
-
-
Save rahim42324/e354094961c19f4d0a4aea970ae72494 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 email, smtplib, ssl | |
| from email import encoders | |
| from email.mime.base import MIMEBase | |
| from email.mime.multipart import MIMEMultipart | |
| from email.mime.text import MIMEText | |
| #The mail addresses and password | |
| sender_email = 'sender123@gmail.com' | |
| password = 'xxxxxxxx' | |
| receiver_address = 'receiver567@gmail.com' | |
| body="This is test email" | |
| message = MIMEMultipart() | |
| message["From"] = "sender123@gmail.com" | |
| message["To"] = "reciver123@gmail.com" | |
| message["Subject"] = "Test Mail" | |
| message["Bcc"] = "reciver123@gmail.com" | |
| message.attach(MIMEText(body, "plain")) | |
| filename = "excel.xlsx" | |
| with open(filename, "rb") as attachment: | |
| part = MIMEBase("application", "octet-stream") | |
| part.set_payload(attachment.read()) | |
| encoders.encode_base64(part) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment