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
- Posted by tru3n0 at 01:59 pm
- Permalink for this entry
- Filed under: Desarrollo
- RSS comments feed of this entry
- TrackBack URI
Good words.