Código:
Formulario para enviar correo php (los detinatarios los capturo en una consulta anterior)Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: Host desconocido. in C:\wamp\www\Activos2\class.smtp.php on line 87 Warning: fsockopen() [function.fsockopen]: unable to connect to mail.marshallyasociados.com:26 (php_network_getaddresses: getaddrinfo failed: Host desconocido. ) in C:\wamp\www\Activos2\class.smtp.php on line 87 Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: Host desconocido. in C:\wamp\www\Activos2\class.smtp.php on line 87 Warning: fsockopen() [function.fsockopen]: unable to connect to mail.marshallyasociados.com:26 (php_network_getaddresses: getaddrinfo failed: Host desconocido. ) in C:\wamp\www\Activos2\class.smtp.php on line 87 Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: Host desconocido. in C:\wamp\www\Activos2\class.smtp.php on line 87 Warning: fsockopen() [function.fsockopen]: unable to connect to mail.marshallyasociados.com:26 (php_network_getaddresses: getaddrinfo failed: Host desconocido. ) in C:\wamp\www\Activos2\class.smtp.php on line 87 Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\Activos2\enviar_correo2.php on line 38
Enviar_Correo.php
Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Sistema de Inventario MyA</title> <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <script src="SpryAssets/SpryValidationTextarea.js" type="text/javascript"></script> <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" /> <link href="SpryAssets/SpryValidationTextarea.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> <!-- function MM_validateForm() { //v4.0 if (document.getElementById){ var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments; for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]); if (val) { nm=val.name; if ((val=val.value)!="") { if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n'; } else if (test!='R') { num = parseFloat(val); if (isNaN(val)) errors+='- '+nm+' must contain a number.\n'; if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); min=test.substring(8,p); max=test.substring(p+1); if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n'; } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; } } if (errors) alert('The following error(s) occurred:\n'+errors); document.MM_returnValue = (errors == ''); } } //--> </script> </head> <body> <form action="enviar_correo2.php" method="post" name="form1" id="form1" enctype="multipart/form-data" onsubmit="MM_validateForm('remitente','','RisEmail','password','','R','nombre','','R','asunto','','R','mensaje','','R');return document.MM_returnValue"> <p align="center"> </p> <div align="center"> <table width="740" border="0" align="left"> <tr> <td width="328"><div align="right"><strong>Correo Remitente:</strong></div></td> <td width="402"><span id="sprytextfield3"> <label> <input type="text" name="remitente" id="remitente" /> </label> <span class="textfieldRequiredMsg">Este valor es requerido.</span></span> <input type="hidden" name="destinos" id="destinos" readonly="readonly" value="<?php echo $_POST['consulta2']; ?>"/></td> </tr> <tr> <td><div align="right"><strong>Password Correo Remitente:</strong></div></td> <td><span id="sprytextfield2"> <label> <input type="password" name="password" id="password" /> </label> <span class="textfieldRequiredMsg">Este valor es requerido.</span></span></td> </tr> <tr> <td><div align="right"><strong>Nombre Remitente:</strong></div></td> <td><span id="sprytextfield1"> <label> <input type="text" name="nombre" id="nombre" /> </label> <span class="textfieldRequiredMsg">Este valor es requerido.</span></span></td> </tr> <tr> <td><div align="right"><strong>Asunto:</strong></div></td> <td><span id="sprytextfield8"> <label> <input type="text" name="asunto" id="asunto" /> </label> <span class="textfieldRequiredMsg">Este valor es requerido.</span></span></td> </tr> <tr> <td><div align="right"><strong>Adjunto:</strong></div></td> <td><span id="sprytextfield9"> <label> <input type="file" name="archivo" id="archivo" /> </label> <span class="textfieldRequiredMsg">Este valor es requerido.</span></span></td> </tr> <tr> <td><div align="right"><strong>Mensaje:</strong></div></td> <td><span id="sprytextarea2"> <label> <textarea name="mensaje" id="mensaje" cols="45" rows="5"></textarea> </label> <span class="textareaRequiredMsg">Este valor es requerido.</span></span></td> </tr> <tr> <td><div align="right"></div></td> <td><label> <input type="submit" name="Submit" id="button" value="Enviar" /> </label> <label> <input type="reset" name="button2" id="button2" value="Reestablecer" /> </label></td> </tr> </table> <p> </p> </div> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"><a href="busqueda_proveedor.php">Regresar/Nueva Búsqueda</a></p> <p> </p> </form> <script type="text/javascript"> <!-- var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3"); var sprytextfield8 = new Spry.Widget.ValidationTextField("sprytextfield8"); var sprytextfield9 = new Spry.Widget.ValidationTextField("sprytextfield9"); var sprytextarea2 = new Spry.Widget.ValidationTextarea("sprytextarea2"); var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1"); var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2"); //--> </script> </body> </html>
Enviar_Correo2.php
Código PHP:
<?php
include "conectarse.php";
$consulta = mysql_query($_POST['destinos']) or die(mysql_error());
$row = mysql_fetch_assoc($consulta);
$intentos=0;
do {
$varname = $_FILES['archivo']['name'];
$vartemp = $_FILES['archivo']['tmp_name'];
//Incluimos la función
require_once('includes/class.phpmailer.php');
//Creamos la instancia de la clase PHPMailer y configuramos la cuenta
$mail=new PHPMailer();
$mail->Mailer="smtp";
$mail->Helo = "www.marshallyasociados.com"; //Muy importante para que llegue a hotmail y otros
$mail->SMTPAuth=true;
$mail->Host="mail.marshallyasociados.com";
$mail->Port=26; //depende de lo que te indique tu ISP. El default es 25, pero nuestro ISP lo tiene puesto al 26
$mail->Username=$_POST['remitente'];
$mail->Password=$_POST['password'];
$mail->From=$_POST['remitente'];;
$mail->FromName="Solicitud de Precios";
$mail->Timeout=60;
$mail->IsHTML(true);
//Enviamos el correo
$mail->AddAddress($row['correo']); //Puede ser Hotmail
$mail->Subject=$_POST['asunto'];
$mail->Body="<p>Texto lo suficientemente largo y con pocos links para que no sea interpretado como SPAM</p><p>Es importante que el texto sea lo suficientemente largo, ya que si sólo tienes por ejemplo, una frase y un link, asume tanto Outlook como la mayoría de los destinatarios, que se trata de SPAM</p><p>Pero si tu texto es largo y tienes un link a <a href\"http://www.forosdelweb.com\">Foros del web</a> por ejemplo, funcionará perfectamente bien.</p>";
$mail->AltBody="Texto que debe decir lo mismo que el Body, pero sin etiquetas HTML";
$exito = $mail->Send();
if ($varname != "")
{
$mail->AddAttachment($vartemp, $varname);
}
while ((!$exito) && ($intentos < 5))
{
sleep(5);
//echo $mail->ErrorInfo;
$exito = $mail->Send();
$intentos=$intentos+1;
}
if($exito){
$mail->ClearAddresses();
echo "<strong>Mensaje enviado exitosamente al correo: </strong>".$row['correo'];
}
else {
$mail->ClearAddresses();
echo "<strong>Error al enviar mensaje al correo: </strong>".$row['correo'];
}
} while ($row = mysql_fetch_assoc($consulta));
include "desconectarse.php";
?>