Tengo este código que ha estado funcionando bien hasta que he migrado de hosting.
Código HTML:
function enviar_email($filename, $mailto, $from_mail, $from_name, $replyto, $subject, $message, $email_tienda) { $copia = "[email protected]"; if(strcmp($filename,"") !== 0) { $file = $filename; $file_size = filesize($file); $handle = fopen($file, "r"); $base64 = fread($handle, $file_size); fclose($handle); unlink($file); } $content = chunk_split(base64_encode(str_replace('data:image/png;base64,','',$base64))); $uid = md5(uniqid(time())); $name = basename($file); $header = "From: ".$from_name." <".$from_mail.">\r\n"; $header .= "Reply-To: ".$replyto."\r\n"; $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n"; $header .= "This is a multi-part message in MIME format.\r\n"; $header .= "--".$uid."\r\n"; $header .= "Content-type:text/html; charset=utf-8\r\n"; $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; $header .= $message."\r\n\r\n"; $header .= "--".$uid."\r\n"; $header .= "Content-Type: application/octet-stream; name=\"".'imagen.png'."\"\r\n"; // use different content types here $header .= "Content-Transfer-Encoding: base64\r\n"; $header .= "Content-Disposition: attachment; filename=\"".'imagen.png'."\"\r\n\r\n"; $header .= $content."\r\n\r\n"; $header .= "--".$uid."--"; if (mail("$mailto,$copia", $subject, "", $header)) { mail($email_tienda, $subject, "", $header); return true; // or use booleans here } else { return false; } } ?>
PHP Warning: mail(): Multiple or malformed newlines found in additional_header in...
Que hace referencia a esta linea:
Código:
He probado en eliminar $header quedando así if (mail("$mailto,$copia", $subject, "", $header)) { mail($email_tienda, $subject, "", $header); return true; // or use booleans here } else {
Código:
Y si funciona, pero evidentemente no me manda el contenido del email. ¿Qué puede ser lo que falla? if (mail("$mailto,$copia", $subject, "")) { mail($email_tienda, $subject, ""); return true; // or use booleans here } else {