Foros del Web » Programando para Internet » PHP »

mail enviado por php se parsea mal en cierto servidor

Estas en el tema de mail enviado por php se parsea mal en cierto servidor en el foro de PHP en Foros del Web. Hola, tengo el siguiente script para mandar mensajes con un archivo adjunto Código: <?php $usermail = $_POST['email']; $name = $_POST['name']; $number = $_POST['number']; $idiomao = ...
  #1 (permalink)  
Antiguo 27/11/2013, 07:35
Avatar de noctovision  
Fecha de Ingreso: marzo-2012
Mensajes: 28
Antigüedad: 12 años, 1 mes
Puntos: 1
mail enviado por php se parsea mal en cierto servidor

Hola, tengo el siguiente script para mandar mensajes con un archivo adjunto

Código:
<?php

$usermail = $_POST['email'];
$name = $_POST['name'];
$number = $_POST['number'];
$idiomao = $_POST['idiomao'];
$idiomad = $_POST['idiomad'];
$filename = $_POST['filename'];
$content  = nl2br($_POST['msg']);

//define the receiver of the email 
$to = '[email protected]'; 
//define the subject of the email 
$subject = 'Mensaje del formulario'; 
//create a boundary string. It must be unique 
//so we use the MD5 algorithm to generate a random hash 
$random_hash = md5(date('r', time())); 
//define the headers we want passed. Note that they are separated with \r\n 
$headers = "From: ".strip_tags($usermail)."\r\nReply-To: ".strip_tags($usermail); 
//add boundary string and mime type specification 
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\""; 
//read the atachment file contents into a string,
//encode it with MIME base64,
//and split it into smaller chunks
$attachment = chunk_split(base64_encode(file_get_contents("../../../../documentos/".$filename))); 
//define the body of the message. 
ob_start(); //Turn on output buffering 
?> 
--PHP-mixed-<?php echo $random_hash; ?>  
Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>" 

--PHP-alt-<?php echo $random_hash; ?>  
Content-Type: text/plain; charset="utf-8" 
Content-Transfer-Encoding: 7bit

Has recibido mensaje nuevo!
Nombre: <?php echo $name ?>
Email: <?php echo $usermail ?>
Teléfono: <?php echo $number ?>
Idioma de origen: <?php echo $idiomao ?>
Idioma de destino: <?php echo $idiomad ?>
Mensaje: <?php echo $content ?>

--PHP-alt-<?php echo $random_hash; ?>  
Content-Type: text/html; charset="utf-8" 
Content-Transfer-Encoding: 7bit

<html><body style="font-family:Arial,sans-serif;">
<h2 style="font-weight:bold;border-bottom:1px dotted #ccc;">Has recibido mensaje nuevo!</h2>
<p><strong>Nombre:</strong> <?php echo $name ?></p>
<p><strong>Email:</strong> <?php echo $usermail ?></p>
<p><strong>Teléfono:</strong> <?php echo $number ?></p>
<p><strong>Idioma de origen:</strong> <?php echo $idiomao ?></p>
<p><strong>Idioma de destino:</strong> <?php echo $idiomad ?></p>
<p><strong>Mensaje:</strong> <?php echo $content ?></p>
</body></html>

--PHP-alt-<?php echo $random_hash; ?>-- 

--PHP-mixed-<?php echo $random_hash; ?>  
Content-Type: application/zip; name="<?php echo $filename; ?>"  
Content-Transfer-Encoding: base64  
Content-Disposition: attachment  

<?php echo $attachment; ?> 
--PHP-mixed-<?php echo $random_hash; ?>-- 

<?php 
//copy current buffer contents into $message variable and delete current output buffer 
$message = ob_get_clean(); 

if(@mail($to, $subject, $message, $headers)) {
	echo "true";
} else {
	echo "false";
}

?>
Funciona bien cuando esta alojando en un hospedaje pero cuando lo hospedo en http://sync-intertainment.com/ los mensajes que manda se ven asi

--PHP-mixed-
4d61ac481b416d2cfa742dfc2201837f
Content-Type: multipart/alternative; boundary="PHP-alt-4d61ac481b416d2cfa742dfc2201837f"

--PHP-alt-4d61ac481b416d2cfa742dfc2201837f
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit

Has recibido mensaje nuevo!
Nombre: potocki jan Teléfono: 0332837625Idioma de origen: AlemánIdioma de destino: AlemánMensaje:
--PHP-alt-4d61ac481b416d2cfa742dfc2201837f
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: 7bit

<html><body style="font-family:Arial,sans-serif;">
<h2 style="font-weight:bold;border-bottom:1px dotted #ccc;">Has recibido mensaje nuevo!</h2>
<p><strong>Nombre:</strong> nowicki jan</p>
<p><strong>Email:</strong> [email protected]</p>
<p><strong>Teléfono:</strong> 0332837625</p>
<p><strong>Idioma de origen:</strong> Alemán</p>
<p><strong>Idioma de destino:</strong> Alemán</p>
<p><strong>Mensaje:</strong> </p>
</body></html>

--PHP-alt-4d61ac481b416d2cfa742dfc2201837f--

--PHP-mixed-4d61ac481b416d2cfa742dfc2201837f
Content-Type: application/zip; name="ok.txt"
Content-Transfer-Encoding: base64
Content-Disposition: attachment

c2R2cw==

--PHP-mixed-4d61ac481b416d2cfa742dfc2201837f--

Alguien sabe porque ser'a?
Gracias

Etiquetas: enviado, formulario, html, mail, servidor, variable
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:56.