diff --git a/pyproject.toml b/pyproject.toml index ee1984e..ebab697 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,9 +38,9 @@ dependencies = [ ] [project.urls] -Documentation = "https://github.com/Micha Albert/carbon-copy#readme" -Issues = "https://github.com/Micha Albert/carbon-copy/issues" -Source = "https://github.com/Micha Albert/carbon-copy" +Documentation = "https://git.mra.sh/mra/carbon-copy#readme" +Issues = "https://git.mra.sh/mra/carbon-copy/issues" +Source = "https://git.mra.sh/mra/carbon-copy" [tool.hatch.version] path = "src/carbon_copy/__about__.py" diff --git a/src/carbon_copy/email_client.py b/src/carbon_copy/email_client.py index 83aa818..d5e2b75 100644 --- a/src/carbon_copy/email_client.py +++ b/src/carbon_copy/email_client.py @@ -3,7 +3,6 @@ # SPDX-License-Identifier: MIT import os -import asyncio import email as email_module from typing import List, Optional, Dict, Any from datetime import datetime, timezone @@ -54,16 +53,12 @@ class EmailConfig: if missing_fields: raise ValueError(f"Missing required environment variables: {', '.join(missing_fields)}") - # Convert port strings to integers after validation - try: - self.smtp_port = int(smtp_port_str) - except ValueError: - raise ValueError(f"SMTP_PORT must be a valid integer, got: {smtp_port_str}") - - try: - self.imap_port = int(imap_port_str) - except ValueError: - raise ValueError(f"IMAP_PORT must be a valid integer, got: {imap_port_str}") + if not smtp_port_str: + raise ValueError("SMTP_PORT must be set in the environment variables") + self.smtp_port = int(smtp_port_str) + if not imap_port_str: + raise ValueError("IMAP_PORT must be set in the environment variables") + self.imap_port = int(imap_port_str) class EmailMessage: @@ -117,6 +112,9 @@ class SMTPClient: else: msg = MIMEText(content, "plain") + if not from_email: + raise ValueError("From email must be provided or set in configuration") + msg["Subject"] = subject msg["From"] = from_email msg["To"] = to_email @@ -135,6 +133,8 @@ class SMTPClient: port=self.config.smtp_port, use_tls=self.config.smtp_use_tls ) as smtp: + if not self.config.smtp_username or not self.config.smtp_password: + raise ValueError("SMTP username and password must be set in configuration") await smtp.login(self.config.smtp_username, self.config.smtp_password) await smtp.send_message(msg)