Tengo un php el cual envia mail a cierto correo, todo funciona perfecto excepto que tengo problemas con los acentos y la Ñ, creo que tengo que codificar a utf8 el envio del mail, la pagina que envio en si....funciona ...el problemas es cuando lo envia al mail, y desde el email no funciona bien las ñ y acentos.
codigo
Código PHP:
#!/usr/bin/php -q
<?php
date_default_timezone_set("America/Santiago");
set_include_path(get_include_path() . PATH_SEPARATOR . '/home8/elarted2/php');
include('Mail.php');
include('Mail/mime.php');
require_once("config.php");
// 'MIME-Version' =>'*1.0',
// 'Content-Transfer-Encoding' => '8bit',
// 'Content-type' => 'text/html;*charset=iso-8859-1'
$headers = "MIME-Version: 1.1\n";
$headers .= "Content-type: text/html; charset=utf-8\n";
$headers = array(
'From' => '[email protected]',
'Return-Path' => '[email protected]',
'Subject' => 'NUEVO MENSAJE DE COMr'
);
$to = '[email protected]';
$month = strftime ("%m");
$day = strftime ("%d");
$year = strftime ("%Y");
$dailyperla = null;
$preview = false;
ob_start();
include "Template.html";
$dailyperla = ob_get_contents();
ob_end_clean();
// reemplazo por string que paresca valido
$dailyperla = str_replace('/[EMAIL]/','/abc123445/', $dailyperla);
$dailyperla;
unlink("perla.html");
file_put_contents("perlas/perla".$day."-".$month."-".$year.".html", $dailyperla);
symlink("perlas/perla".$day."-".$month."-".$year.".html", "perla.html");
$newmime = new Mail_mime();
$newmime->setTXTBody('Perla de Conocimiento');
$newmime->setHTMLBody($dailyperla);
$body = $newmime->get();
$hdrs = $newmime->headers($headers);
$mail = &Mail::factory('mail');
utf8_decode($mail);
if($mail->Send($to, $hdrs, $body) )
{
echo "***************************";
echo "<br />";
echo "mensaje enviado con exito!";
echo "<br />";
echo "***************************";
}
else
{
echo "fallo envio";
}
?>
El mail se envia, el html se ve en correo...pero hay solo unos pequeños dramas con las Ñ y acentos, si me dirigo a Template.html desde el navegador funciona perfecto....espero me puedan ayudar.