<?php/* Esta es una Clase de PEAR que tenemos instalada en los
servidores por eso solo hace falta llamarla */require'Net/SMTP.php';
// inicio editable$host = 'smtp.DOMINIO.COM';
$from = 'USUARIO@DOMINIO.COM';
$pass = "CONTRASEÑA"; // contraseña del usuario $from$rcpt = array('USUARIO@DESTINO.COM');
$subj = "Subject: ASUNTO\n";
$body = "CUERPO DEL MENSAJE";
// fin editable/*Creamos un nuevo objeto para Net_SMTP, indicando
que el puerto es el 2525 (MUY IMPORTANTE para Mailing)*/if(! ($smtp = new Net_SMTP($host, '2525'))){die("Unable to instantiate Net_SMTP object\n");
}//Nos conectamos al Servidor SMTP.if(PEAR::isError($e = $smtp->connect())){die($e->getMessage() . "\n");
}if(PEAR::isError($res = $smtp->auth($from,$pass))){die("Unable to authenticate : " . $res->getMessage() . "\n");
}// Enviamos los comandos al SMTP 'MAIL FROM:'.if(PEAR::isError($smtp->mailFrom($from))){die("Unable to set sender to <$from>\n");
}// Agregamos las direcciones de los destinatariosforeach($rcptas$to){if(PEAR::isError($res = $smtp->rcptTo($to))){die("Unable to add recipient $to: " . $res->getMessage() . "\n");
}}// Armamos el BODY del mensajeif(PEAR::isError($smtp->data("From: $from\r\nTo: $to\r\n".$subj."\r\n".$body))){die("Unable to send data\n");
}// Para terminar nos desconectamos del Servidor SMTP$smtp->disconnect();
?>
¿Qué te pareció este artículo?
Esta página fue modificada por última vez el 16:19, 11 ago 2007.