#!/usr/bin/env python3
"""Test script to send a signup notification email to admin"""

from app import app
from flask_mail import Message
from email_config import mail

def send_test_signup_notification():
    """Send a test signup notification email"""
    with app.app_context():
        try:
            msg = Message(
                'TEST: New EPOLaw Signup - Potential Upsell Opportunity',
                sender=app.config.get('MAIL_USERNAME', 'noreply@epolaw.com'),
                recipients=['scott@seguelogic.com']
            )
            msg.html = '''
            <h2>TEST EMAIL - New User Signup</h2>
            <p>This is a test of the signup notification system.</p>
            <p>A new user has signed up for a free account:</p>
            <ul>
                <li><strong>Name:</strong> Test User</li>
                <li><strong>Email:</strong> testuser@example.com</li>
                <li><strong>Organization:</strong> Test Law Firm</li>
                <li><strong>Company:</strong> Test User's Practice</li>
                <li><strong>Plan:</strong> Free</li>
            </ul>
            <p>This is a potential upsell opportunity to Professional or Enterprise plan.</p>
            <p><strong>Note:</strong> This is a test email. No actual signup occurred.</p>
            '''

            print("Sending test email...")
            print(f"To: scott@seguelogic.com")
            print(f"Subject: TEST: New EPOLaw Signup - Potential Upsell Opportunity")
            print(f"Mail server: {app.config.get('MAIL_SERVER')}:{app.config.get('MAIL_PORT')}")

            mail.send(msg)

            print("✅ Test email sent successfully!")
            return True

        except Exception as e:
            print(f"❌ Failed to send test email: {e}")
            import traceback
            traceback.print_exc()
            return False

if __name__ == '__main__':
    send_test_signup_notification()
