Skip to content

Instantly share code, notes, and snippets.

@rahim42324
Last active November 7, 2020 04:52
Show Gist options
  • Select an option

  • Save rahim42324/e354094961c19f4d0a4aea970ae72494 to your computer and use it in GitHub Desktop.

Select an option

Save rahim42324/e354094961c19f4d0a4aea970ae72494 to your computer and use it in GitHub Desktop.
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