<?php
function sendTodosDibujamos(){
    $correosField = get_field('modal_contacto', 'options');
    $correosField = $correosField['formulario']['correos_destino'];
    $correos = array();
    $file = $_POST['file'];
    $name = $_POST['name'];
    $htmlData = $_POST['html'];

    $count = 0;
    $url = get_template_directory_uri();

    // print_r($name);
    // die();

    $tema = '';
    $tema .='<table align="center" cellpadding="0" cellspacing="0" width="600" style="border-collapse: collapse;">';
    $tema .='    <tr>';
    $tema .='        <td align="center" bgcolor="white" style="padding: 40px 0 30px 0;">';
    $tema .='            <img src="'.$url.'/assets/images/logo.png" style="width: 40%">';
    $tema .='        </td>';
    $tema .='    </tr>';
    $tema .='    <tr>';
    $tema .='        <td  style="padding: 20px 20px">';
    $tema .='            <table cellpadding="0" cellspacing="0" width="100%">    ';
    $tema .='                <tr>';
    $tema .='                    <td>';
    $tema .='                       <h3>Todos dibujamos.</h3>';
    $tema .='                    </td>';
    $tema .='                </tr>    ';
    $tema .='                <tr>';
    $tema .='                    <td style="padding: 20px 0 30px 0;">';
    $tema .= $htmlData;
    $tema .='                    </td>    ';
    $tema .='                </tr>    ';
    $tema .='            </table>';
    $tema .='        </td>';
    $tema .='    </tr>';
    $tema .='    <tr>';
    $tema .='        <td align="center" bgcolor="white" style="padding: 20px 0 30px 0;">';
    $tema .='            © '.date("Y").' Yesterman. Todos los derechos reservados. ';
    $tema .='        </td>';
    $tema .='    </tr>';
    $tema .='</table>';

    foreach ($correosField as $correo) {
        $correos[$correo['correo']] = "Yesterman | Todos dibujamos";
    }
    // $correo_indi = $mails_arr;
    // $correos[$correo_indi] = 'Yesterman';
    // print_r('aqui');

    include 'Mailin.php';
    $mailin = new Mailin("https://api.sendinblue.com/v2.0","2p0HQYRVFWK7GJq3");
    $data = array( "to" => $correos,
        "from" => array("no-reply@yesterman.com", "no-reply - Yesterman"),
        "replyto" => array("no-reply@yesterman.com", "Yesterman"),
        "subject" => "Yesterman - todos dibujamos",
        "html" => $tema,
        "attachment" => array($name => $file)
    );
    $resp = $mailin->send_email($data);
    print_r(json_encode($resp));
    die();
}



?>