Errore di autenticazione nella connessione smpt ssl a gmail sulla porta 465
Ciao a tutti,
nel mio sito ho messo un modulo per inviarmi una mail che poi richiama uno script che vi riporto sotto,
il problema è che se lo eseguo in locale (sul mio pc) funziona benissimo e la mail mi arriva,
mentre se lo eseguo su altervista mi da un errore di autenticazione
Codice:
Fatal error: Uncaught exception 'phpmailerException' with message 'SMTP Error: Could not authenticate.' in /membri/magocarlos99/php/lib/PHPMailer/class.phpmailer.php:1638 Stack trace: #0 /membri/magocarlos99/php/lib/PHPMailer/class.phpmailer.php(1486): PHPMailer->smtpConnect(Array) #1 /membri/magocarlos99/php/lib/PHPMailer/class.phpmailer.php(1323): PHPMailer->smtpSend('Date: Mon, 5 Se...', 'This is a multi...') #2 /membri/magocarlos99/php/lib/PHPMailer/class.phpmailer.php(1203): PHPMailer->postSend() #3 /membri/magocarlos99/php/mail.php(40): PHPMailer->send() #4 {main} thrown in /membri/magocarlos99/php/lib/PHPMailer/class.phpmailer.php on line 1638
come se altervista bloccasse la connessione ssl della funzione che autentica sul server di google.
Questo è lo script:
Codice PHP:
$a="mio-indirizzo@email.it";
$mail = new PHPMailer(true);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "email-di-google@gmail.com"; // GMAIL username
$mail->Password = "password"; // GMAIL password
$mail->AddAddress($a, "Nome");
$mail->SetFrom("contatti@sito.it", "Da");
$mail->AddReplyTo($email, $nome);
$mail->Subject = "Nuova mail dal sito";
$mail->IsHTML(true);
$mail->Body = "<h3>Corpo dell'email in html</h3>";
$mail->AltBody="Corpo dell'email in testo";
if(!$mail->Send())
header("location: ../pagine/contatti.php?res=errore#email");
else
header("location: ../pagine/contatti.php?res=ok#email");
Come posso risolvere il problema?
grazie,
Carlo