diff --git a/mail_template.html b/mail_template.html new file mode 100644 index 0000000..d6f12f4 --- /dev/null +++ b/mail_template.html @@ -0,0 +1,85 @@ + + + + + + Event Invitation + + + +
+
+

You're Invited!

+

[Event Name] on [Event Date]

+
+
+

Dear [Recipient's Name],

+

I hope this message finds you well! We are excited to invite you to [Event Name] on [Event Date] at [Event Location/Online Platform].

+

Event Details:

+ +

We would love to have you join us and look forward to your presence at this special event.

+

If you have any questions or need additional information, feel free to reach out.

+
+
+ RSVP Now +
+ +
+ + diff --git a/src/sender.py b/src/sender.py index 802e068..5c0ad7f 100644 --- a/src/sender.py +++ b/src/sender.py @@ -11,9 +11,13 @@ if __name__ == "__main__": subject = "Test Email" - body = "This is a test email sent from Python!" - to_emails = ["ertugrul.a.senturk@gmail.com"] * 10 + try: + with open("mail_template.html") as body_file: + body = body_file.read() + except Exception as e: + print("Could not open mail body file: ", e) + exit(1) apply_log_config() diff --git a/src/services/email_service.py b/src/services/email_service.py index 4c431ed..dd7d767 100644 --- a/src/services/email_service.py +++ b/src/services/email_service.py @@ -18,7 +18,8 @@ def send_emails(smtp_server: str, smtp_port: int, username: str, password: str, msg['Subject'] = subject # Attach the email body - msg.attach(MIMEText(body, 'plain')) + msg.attach(MIMEText(body, 'html')) + try: server.send_message(msg) print(f"Email sent to {to_email}")