\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "X-Mailer: PHP/".phpversion()."\r\n";
// Obter os dados dos emails diretamente do formulário
$lines = explode("\n", $to);
$i = 0;
$count = 1;
$ok = "ok";
while(isset($lines[$i])) {
$line = trim($lines[$i]);
if (!$line) {
$i++;
continue;
}
// Dividir a linha em partes
list($current_email, $cnpj, $razao, $telefone, $socio) = explode(';', $line) + [null, null, null, null, null];
$current_email = trim($current_email);
$subject = $_POST['assunto'];
$message = $_POST['html'];
if ($current_email) {
// Substituir as tags no assunto e mensagem
$message = str_replace(['{{cnpj}}', '{{razao}}', '{{telefone}}', '{{socio}}', '%EMAIL%', '%random_num%'],
[trim($cnpj), trim($razao), trim($telefone), trim($socio), $current_email, random_num()],
$message);
$subject = str_replace(['{{cnpj}}', '{{razao}}', '{{telefone}}', '{{socio}}', '%EMAIL%', '%random_num%'],
[trim($cnpj), trim($razao), trim($telefone), trim($socio), $current_email, random_num()],
$subject);
$message = stripslashes($message);
// Enviar o email
if(mail($current_email, $subject, $message, $headers))
echo "* Numero: $count ".$current_email." OK