Possible Duplicate:
Having trouble with PHPMailerphpmailer inviare SMTP di Gmail timeout
Ci sono un sacco di domande simili, ma nessuno di loro mi ha aiutato.
Ecco il mio script che è fornito nelle exmaples PHPMailer:
require_once('../class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP(); // telling the class to use SMTP
try {
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
$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 protected]"; // GMAIL username
$mail->Password = "yourpassword"; // GMAIL password
$mail->AddReplyTo('[email protected]', 'First Last');
$mail->AddAddress('[email protected]', 'John Doe');
$mail->SetFrom('[email protected]', 'First Last');
$mail->AddReplyTo('[email protected]', 'First Last');
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->MsgHTML("some message");
$mail->Send();
echo "Message Sent OK</p>\n";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
ed ecco l'errore:
SMTP -> ERROR: Failed to connect to server: Connection timed out (110)
SMTP Error: Could not connect to SMTP host.
a molte domande è stato menzionato per consentire php_openssl extenstion
che è abilitato in mio assistente. Sto usando PHPMailer versione 5.1
anche non c'è nessun problema con la mia porta del server 25 e semplice funzione mail()
funziona bene
Grazie per il vostro aiuto
eseguire il ping dell'host \ port dallo stesso server, nel caso si verifichi un problema di rete –
@Dagon: eseguire il ping senza problemi. Ho anche provato a localhost, e c'è lo stesso problema. Ho inviato molte e-mail usando questo approccio diversi mesi fa e funzionava bene, ma ora ho dimenticato come ... – Aliweb