import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

email_server = 'smtp.titan.email'
email_port = 587
email_address = 'info@spxbutterflies.com'
email_password = 'Daleriver11$s'

# Configura los detalles del correo electrónico
sender_email = email_address
# receivers1 = ['seba34e@gmail.com', 'nebuco@gmail.com', 'lermit.diaz@fmcarbide.com', 'gotec33345@wikfee.com', 'moris.ferrer@gmail.com', 'jjvch@yahoo.com', 'bnuneznova@gmail.com', 'juceurgo@gmail.com', 'alexism6767@gmail.com', 'acermgs@yahoo.com.mx']
# receivers2 = ['canossa@bellsouth.net', 'jd1830@gmail.com', 'hector.i.gutierrez.lopez@gmail.com', 'xnoklon@hotmail.com', 'yosmaruho1978@gmail.com', 'majvg.009@gmail.com', 'emersonflores731@gmail.com', 'dggatonn@gmail.com', 'cpessantotlm@gmail.com', 'ferm2006@gmail.com']
# receivers3 = ['ghanimachado@gmail.com', 'inversionestt@gmail.com', 'options.jopa@gmail.com', 'nuriaggz@gmail.com', 'luis_hinos@hotmail.com', 'santanero3@netzero.com', 'fbrussa@gmail.com','carozin@live.com.mx', 'paumarce.alvarez@gmail.com', 'matias.delacruz@gmail.com']
# receivers4 = ['mauricioloiero@gmail.com', 'jcantuarias@gmail.com', 'vmolinap@msn.com', 'makoavil@hotmail.com', 'tomasperera@gmail.com', 'rolandocuba96@gmail.com', 'alie.morata@gmail.com', 'setrabaja01@gmail.com', 'estebanvillalba1192@gmail.com', 'mmdb11@hotmail.com']
# receivers5 = ['tosymoco@gmail.com', 'karimdiaz1@hotmail.com', 'zapatiga@gmail.com', 'eliho74@yahoo.com', 'mauriciog_50@hotmail.com', 'francisco@monumentor.org', 'Henry.bender87@gmail.com', 'iaccfa@hotmail.com', 'dbaselica@gmail.com', 'mvaldes68@yahoo.com.ar']
# receivers6 = ['pfsancho@gmail.com', 'crdaarp@hotmail.com', 'arcegk@gmail.com', 'huh@hh.bc']

# receivers = ['seba34e@gmail.com','seba34e@hotmail.com']

for receiver in receivers6:
    # Crea el mensaje MIME multipart
    message = MIMEMultipart()
    sender_name = 'SPX BUTTERFLIES'  # Nombre del remitente personalizado
    # Establece el remitente personalizado
    message['From'] = f'{sender_name} <{sender_email}>'
    message['To'] = receiver
    message['Subject'] = '¡Welcome to SPX Butterflies! / ¡Bienvenido a SPX Butterflies!'

    # Contenido del mensaje en formato HTML
    html_content = """
    <!DOCTYPE html>
    <html lang="es">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>¡Welcome to SPX Butterflies! / ¡Bienvenido a SPX Butterflies!</title>
        <style>
            body {
                font-family: Arial, sans-serif;
                background-color: #f4f4f4;
                margin: 0;
                padding: 0;
            }
            .container {
                max-width: 600px;
                margin: 0 auto;
                padding: 20px;
                background-color: #ffffff;
                border-radius: 10px;
                box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            }
            .content {
                margin-top: 20px;
            }
            h2 {
                color: #333333;
                background-color: #007bff;
                padding: 10px;
                border-radius: 10px 10px 0 0;
                margin-top: 0;
                margin-bottom: 10px;
            }
            .content-en, .content-es {
                background-color: #f0f0f0;
                padding: 10px;
                border-radius: 0 0 10px 10px;
            }
            p {
                margin-bottom: 10px;
            }
            a {
                text-decoration: none;
                color: #007bff;
            }
            a:hover {
                text-decoration: underline;
            }
        </style>
    </head>
    <body>
        <div class="container">
            <div class="content">
                <h2>ENGLISH</h2>
                <div class="content-en">
                    <p>If you received this email it's because at some point you subscribed to the website <a href="http://www.spxbutterflies.com" target="_blank" style="color: #007bff;">www.spxbutterflies.com</a>.</p>
                    <p>This email is to grant you a free subscription for 30 days with full access to all modules of the platform so you can try it out and rely on statistics to improve your trading.</p>
                    <p>The extension of the membership is already applied to your account. You don't need to do anything.</p>
                    <p>Access the website from <a href="http://www.spxbutterflies.com" target="_blank" style="color: #007bff;">www.spxbutterflies.com</a>, enter your credentials, and enjoy the wonderful world of butterflies on Wall Street!!!</p>
                    <p>Any questions or suggestions can be made <a href="http://www.spxbutterflies.com/contact" target="_blank" style="color: #007bff;">here</a>.</p>
                </div>
            </div>
            <div class="content">
                <h2>ESPAÑOL</h2>
                <div class="content-es">
                    <p>Si recibiste este correo electrónico es porque en algún momento te suscribiste al sitio web <a href="http://www.spxbutterflies.com" target="_blank" style="color: #007bff;">www.spxbutterflies.com</a>.</p>
                    <p>Este correo electrónico es para otorgarte una suscripción gratuita por 30 días con acceso completo a todos los módulos de la plataforma para que puedas probarla y confiar en las estadísticas para mejorar tu trading.</p>
                    <p>La extensión de la membresía ya está aplicada a tu cuenta. No necesitas hacer nada.</p>
                    <p>Accede al sitio web desde <a href="http://www.spxbutterflies.com" target="_blank" style="color: #007bff;">www.spxbutterflies.com</a>, ingresa tus credenciales y ¡disfruta del maravilloso mundo de las mariposas en Wall Street!!!</p>
                    <p>Cualquier pregunta o sugerencia se puede realizar <a href="http://www.spxbutterflies.com/contact" target="_blank" style="color: #007bff;">aquí</a>.</p>
                </div>
            </div>
        </div>
    </body>
    </html>
    """

    # Adjunta el contenido HTML al mensaje
    html_part = MIMEText(html_content, 'html')
    message.attach(html_part)

    # Inicia una conexión SMTP y envía el correo electrónico
    try:
        server = smtplib.SMTP(email_server, email_port)
        server.starttls()
        server.login(email_address, email_password)
        server.sendmail(sender_email, receiver, message.as_string())
        print("Correo electrónico enviado con éxito!")
    except Exception as e:
        print("Error al enviar el correo electrónico:", e)

server.quit()
