Files
RTG/scrapper/Basic/send_email.py
2026-06-19 20:08:01 +06:00

42 lines
1.3 KiB
Python

import smtplib
from email.mime.text import MIMEText
def send_email(subject,message):
print('-- Email Sending --')
# Configuration
port = 587
smtp_server = "smtp.gmail.com"
login = "noreply.readytogoletters@gmail.com" # Your login generated by Mailtrap
password = "fymebmopnajzwkfb"
sender_email = "test.velocity@gmail.com"
# port = 587
# smtp_server = "sandbox.smtp.mailtrap.io"
# login = "b879299bf7dd9a"
# password = "3c1ee98e9ddeb7"
# sender_email = "pulak.deb@softrobotics.com.bd"
# List of recipient email addresses
receiver_emails = ["rajibcuetcse@gmail.com","bpulakd@gmail.com"]
#receiver_emails = ["bpulakd@gmail.com"]
text = f"{message}"
message = MIMEText(text, "plain") # Create MIMEText object
message["Subject"] = subject
message["From"] = sender_email
message["To"] = ", ".join(receiver_emails) # Join the list of receiver emails into a string separated by commas
# Send the email
with smtplib.SMTP(smtp_server, port) as server:
server.starttls() # Secure the connection
server.login(login, password)
# Loop through each recipient and send the email individually
for recipient in receiver_emails:
server.sendmail(sender_email, recipient, message.as_string())
print('Sent')