Spaces:
Sleeping
Sleeping
File size: 1,165 Bytes
1273f44 8384194 e39877e 1273f44 e39877e 1273f44 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
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()
|