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-&gt;Port;</blockquote>
<blockquote># Modificación
if (preg_match(‘#(([a-z]+://)?[^:]+):(d+)#i’, $hosts[$index], $match))
{
$host = $match[1];
$port = $match[3];
}
else
{
$host = $hosts[$index];
$port = $this-&gt;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

Categorized: Uncategorized
Tagged:

One comment on “Utilizar PHPMailer con una cuenta de Gmail

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>