Neny_16 User destacando


Registrado: 27 May 2006
Mensajes: 279
|
Publicado: Vie Feb 03, 2012 8:17 pm Título del mensaje: PHPMailer |
|
|
Hola!!!
Tengo un problema enviando emails con el phpmailer.
Hay veces que me sale: SMTP Error: Could not authenticate. Error: SMTP Error: Could not authenticate.
y otras veces me sale: SMTP Error: Could not connect to SMTP host
Error mailing: SMTP error:Could not connect to SMTP host
Ah, he decomentado del php.ini --> extension=php_openssl.dll
Pero tampoco me va.
Lo veis bien?
| Código: |
function enviarEmail($email, $dni, $cad){
require_once("../PHPMailer_v5.1/class.phpmailer.php");
//require_once("../PHPMailer_v5.1/class.smtp.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Mailer = "smtp";
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = "xxx@gmail.com"; // GMAIL username
$mail->Password = "xxx"; // GMAIL password
$mail->From = "admin@tktbrainpower.com";
$mail->FromName = "Empresa";
$mail->Subject = "Dades usuari de la empresa";
$body="En aquest moment ja es usuari de la nostra pagina web. <br>Esta registrat al nostre sistema amb les seguents dades: <br> DNI: $dni<br> E-mail: $email<br> Contrassenya: $cad<br><br>Per validar el seu usuari, ha d'entrar a la seguent pagina que li indiquem: <a href='http://127.0.0.1:8888/Empresa - copia (21)/web/funcions.php?funcio=validar_user&dni=$dni'> http://www.Mintidea.com </a>";
$mail->AltBody = "Per veure el missatge, utilitzi un visor de email HTML compatible!"; // variable opcional
$mail->MsgHTML($body);
//$mail->AddAttachment("files/files.zip");
//$mail->AddAttachment("files/img03.jpg");
$mail->AddAddress($email, "Destinatario");
$mail->IsHTML(true);
if(!$mail->Send()) {
echo "Error: " . $mail->ErrorInfo;
} else {
echo "Mensaje enviado correctamente";
}
} |
|
|