import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart import os # Sender and receiver sender_email = "marcoioitsoft@gmail.com" receiver_emails = ["vikasnale@gmail.com", "vikas@marcoaiot.com"] password = "qrtq wfuj hwpp fhqr" # Use Gmail App Password here # Read body from text file (e.g., body.txt in the same folder) file_path = os.path.join(os.path.dirname(__file__), "body.txt") with open(file_path, "r", encoding="utf-8") as f: body = f.read() # Create the email message = MIMEMultipart() message["From"] = sender_email message["To"] =", ".join(receiver_emails) message["Subject"] = "Test Email from Python" # Attach body message.attach(MIMEText(body, "html")) try: # Connect to Gmail SMTP server server = smtplib.SMTP("smtp.gmail.com", 587) server.starttls() # Secure the connection server.login(sender_email, password) server.sendmail(sender_email, receiver_emails, message.as_string()) print("✅ Email sent successfully!") except Exception as e: print("❌ Error:", e) finally: server.quit()