Utilizar PHPMailer con una cuenta de Gmail

Hay 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 -> AddAddress (“bar@domain.com”);
$mail -> Subject = “Test”;
$mail -> Body = “<h3>From GMail!</h3>”;
$mail -> IsHTML (true);

$mail->IsSMTP();
$mail->Host = ’ssl://smtp.gmail.com’;
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->Username

Vía buayacorp

Filed under Desarrollo.
 

1 Response to Utilizar PHPMailer con una cuenta de Gmail

  1. Laraine

    Good words.

  2.  

Leave a Reply