Spaces:
Sleeping
Sleeping
| import os | |
| import logging | |
| from dotenv import load_dotenv | |
| # Load environment variables from .env file immediately | |
| load_dotenv() | |
| import sys | |
| import os | |
| # Add parent directory to path | |
| sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) | |
| from services.email_service import send_email | |
| # Configure logging | |
| logging.basicConfig(level=logging.INFO) | |
| logger = logging.getLogger(__name__) | |
| def test_email_sending(): | |
| email_id = os.getenv("EMAIL_ID") | |
| if not email_id: | |
| logger.error("EMAIL_ID not found in environment variables.") | |
| return | |
| logger.info(f"Testing email sending to {email_id}...") | |
| # Debug config | |
| from services.email_service import SMTP_SERVER, SMTP_PORT | |
| logger.info(f"Using SMTP Server: {SMTP_SERVER}:{SMTP_PORT}") | |
| subject = "Test Email from API Gateway" | |
| body = "This is a test email to verify that the email credentials in .env are working correctly." | |
| success = send_email(email_id, subject, body) | |
| if success: | |
| logger.info("Email sent successfully!") | |
| else: | |
| logger.error("Failed to send email.") | |
| if __name__ == "__main__": | |
| test_email_sending() | |