cetutnx1
New Member
- Messages
- 510
- Reaction score
- 0
- Points
- 0
Hola, en realidad este no es un "problema del servidor", pero necesitaría ayuda.
He creado un newsletter, pero el correo enviado a hotmail llega perfecto, pero con el contenido vacío.
Les dejo el código si alguien tiene una solución por favor la estoy necesitando hace más de 2 semanas que este script me tiene un poco arto...
Aquí está, está alojado en este hosting:
He creado un newsletter, pero el correo enviado a hotmail llega perfecto, pero con el contenido vacío.
Les dejo el código si alguien tiene una solución por favor la estoy necesitando hace más de 2 semanas que este script me tiene un poco arto...
Aquí está, está alojado en este hosting:
PHP:
<?php
ERROR_REPORTING(E_ALL);
define('ACCESS',true);
require("../includes/config.inc.php");
require("admin.inc.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Sistema de Administracion de Newsletter</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="autor" content="Gonzalo García" />
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
_editor_url = "../editor/" // (preferably absolute) URL (including trailing slash) where Xinha is installed
_editor_lang = "es"; // And the language we need to use in the editor.
</script>
<script type="text/javascript" src="../editor/htmlarea.js"></script>
<script type="text/javascript" src="../editor/config.js"></script>
</head>
<body class="content">
<h1>Enviar Correo</h1>
<div id="todo">
<?php
$step = $_GET['step'];
if(!isset($step)) {
$list = $_GET['list'];
?>
<form id="editors_here" method="post" enctype="multipart/form-data" action="sendmail.php?step=2">
<table>
<tbody>
<tr>
<td style="text-align: left;"><label for="para" title="Para:">Para: </label></td>
<td>
<select name="para" id="para" style="width: 350px;">
<option value=""<?php if ($list == "") {printf(" selected=\"selected\"");} ?>> - Seleccione Una Carrera - </option>
<option value="civil"<?php if ($list == "civil") {printf(" selected=\"selected\"");} ?>>Ing. Civil</option>
<option value="electrica"<?php if ($list == "electrica") {printf(" selected=\"selected\"");} ?>>Ing. Eléctrica</option>
<option value="electronica"<?php if ($list == "electronica") {printf(" selected=\"selected\"");} ?>>Ing. Electrónica</option>
<option value="industrial"<?php if ($list == "industrial") {printf(" selected=\"selected\"");} ?>>Ing. Industrial</option>
<option value="mecanica"<?php if ($list == "mecanica") {printf(" selected=\"selected\"");} ?>>Ing. Mecánica</option>
<option value="metalurgica"<?php if ($list == "metalurgica") {printf(" selected=\"selected\"");} ?>>Ing. Metalúrgica</option>
<option value="quimica"<?php if ($list == "quimica") {printf(" selected=\"selected\"");} ?>>Ing. Química</option>
<option value="sistema"<?php if ($list == "sistema") {printf(" selected=\"selected\"");} ?>>Ing. Sistemas</option>
<option value="ingresante"<?php if ($list == "ingresante") {printf(" selected=\"selected\"");} ?>>Ingresantes</option>
<option value="todos"<?php if ($list == "all") {printf(" selected=\"selected\"");} ?>>Todos</option>
</select>
</td>
</tr>
<tr>
<td style="text-align: left;"><label for="asunto" title="Asunto:">Asunto: </label></td>
<td><input type="text" name="asunto" id="asunto" style="width: 350px;" /></td>
</tr>
<tr>
<td>
Adjuntar Archivo:
</td>
<td>
<input type="file" name="adjunto" id="adjunto" />
</td>
</tr>
<tr>
<td colspan="2">
<label title="Cuerpo del mensaje">
<textarea name="mensaje" id="mensaje" style="width: 100%; height: 320px;"></textarea>
</label>
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Enviar Correo" />
</td>
</tr>
</tbody>
</table>
</form>
<?php
}
elseif($step == 2) {
//Averiguo para quien es el mail...
$para = $_POST['para'];
$asunto = $_POST['asunto'];
$adjunto = $_FILES['adjunto'];
$contenido = $_POST['mensaje'];
$contenido = stripslashes($contenido);
$contenido_plano = strip_tags($contenido);
$bid = "----------=_".time(); //Identificador único de boundary(no se que es pero igual lo pongo)
$boundary = "boundary=\"".$bid."\"";
//Aquí estan las cabeceras del mensaje
$cabeceras = "From: ".$config['from']."\r\n";
$cabeceras .= "Reply-To: ".$config['reply']."\r\n";
$cabeceras .= "Return-path: ".$config['reply']."$\r\n"
$cabeceras .= "Message-ID: <cet-utn@".$_SERVER['SERVER_NAME'].">\r\n"
$cabeceras .= "X-Mailer: PHP/".phpversion()."\r\n";
$cabeceras .= "Date: ".$mail['fecha']."\r\n";
$cabeceras .= "MIME-Version: 1.0\r\n";
if($adjunto['size'] != 0) {
$cabeceras .= "Content-Type: multipart/mixed;".$boundary."\r\n\r\n";
$cabeceras .= "\r\nThis is a multi-part message in MIME format.\r\n\r\n";
$fd = fopen($adjunto['tmp_name'], "r");
$contents = fread($fd, filesize($adjunto['tmp_name']));
$encoded = chunk_split(base64_encode($contents));
fclose($fd);
$mensaje .= "Content-Type: application/octet-stream; name=\"".$adjunto['name']."\"\r\n";
$mensaje .= "Content-Transfer-Encoding: base64\r\n";
$mensaje .= "Content-Disposition: attachment; filename=\"".$adjunto['name']."\"\r\n";
$mensaje .= $encoded;
$mensaje .= "\r\n--".$bid."\r\n";
}
else {
$cabeceras .= "Content-Type: multipart/alternative;".$boundary."\r\n\r\n";
$cabeceras .= "\r\nThis is a multi-part message in MIME format.\r\n\r\n";
}
$mensaje = "--$bid\r\n";
//Mensaje en texto plano
$mensaje .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$mensaje .= "Content-Transfer-Encoding: 7bit\r\n";
$mensaje .= "\r\n".$contenido_plano."\r\n";
//Mensaje en html
$mensaje .= "--$bid\r\n";
$mensaje .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
$mensaje .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$mensaje .= "<html>\n <body>\n";
$mensaje .= $contenido;
$mensaje .= " </body>\n</html>\n";
$mensaje .= "\r\n--".$bid."\r\n";
//La función mail de php no permite mandar
//lineas que sean más largas que 70 caracteres
$mensaje = wordwrap($mensaje, 70);
// save_mail($para,$asunto,$mensaje,$cabeceras);
printf($cabeceras);
printf($mensaje);
if($para != "todos" && $para != "") {
$location = $listdir;
$prefix = $config['file']."_";
$file = $location.$prefix.$para.".csv";
//Abro el archivo de contectos
$newfile = fopen($file,"r");
$content = fread($newfile, filesize($file));
//Separo los emails
$lines = explode("\n",$content);
fclose($newfile);
$sended = 0;
$nosended = 0;
$who_yes = "";
$who_no = "";
/* foreach($lines as $l) {
$l = trim("$l");
$l = strtolower("$l");
if($l != "dirección de correo electrónico" && $l != "") {*/
$l = "ggarcia_24@hotmail.com, ggarcia_24@argentina.com, ema056@yahoo.com.ar, ealtamira@sae.frc.utn.edu.ar,50835@electronica.frc.utn.edu.ar";
if(mail($l, $asunto, $mensaje, $cabeceras)) {
$sended++;
$who_yes .= $l."<br />\n";
}
else {
$nosended++;
$who_no .= $l."<br />\n";
}
/*}
}*/
}
elseif ($para == "todos") {
$location = $listdir;
$prefix = $config['file']."_";
$file = $location.$prefix."all.csv";
//Abro el archivo
$newfile = fopen($file,"r");
$content = fread($newfile, filesize($file));
//Separo nombre, apellidos, y email
$lines = explode("\n",$content);
fclose($newfile);
foreach($lines as $l) {
$l = trim("$l");
$l = strtolower("$l");
if($l != "dirección de correo electrónico" && $l != "") {
if(mail($l, $asunto, $mensaje, $cabeceras)) {
$sended++;
$who_yes .= $l."<br />\n";
}
else {
$nosended++;
$who_no .= $l."<br />\n";
}
}
}
}
printf("Se han enviado correctamente $sended emails<br />");
printf("No se han enviado correctamente $nosended emails <br />");
printf("A: <br />$who_no");
}
?>
</div>
</body>
</html>