Utilizar PHPMailer con una cuenta de Gmail
Tuesday, December 11th, 2007Hay que hacer algunos cambios en el fichero class.phpmailer.php en la línea 573 para poder utilizar SSL/TLS
# Original
if(strstr($hosts[$index], “:”))
list($host, $port) = explode(“:”, $hosts[$index]);
else
{
$host = $hosts[$index];
$port = $this->Port;
# Modificación
if (preg_match(‘#(([a-z]+://)?[^:]+):(\d+)#i’, $hosts[$index], $match))
{
$host = $match[1];
$port = $match[3];
}
else
{
$host = $hosts[$index];
$port = $this->Port;
}
Ejemplo de prueba:
require_once ‘class.phpmailer.php’;
$mail = new PHPMailer ();
$mail -> From = “foo@gmail.com”;
$mail -> FromName = “Foo”;
$mail -> [...]