Domanda

Ho scaricato l'ultimo aggiornamento di XAMPP, che più o meno incasinato la mia vecchia configurazione. Ero ad un certo punto in grado di inviare la posta di base () con PHP, ma una volta ho aggiornato si è fermato.

ho studiato un po 'e tutti raccomandato Zend o PHPMailer. Ho provato PHPMailer, mi ha restituito un errore che dice cound non ottenere una risposta.

pasticciato con il mio php.ini e ha aumentato il timeout presa da 60 a 120. Questo non funzionava, così ho provato l'invio di mail di prova a me stesso.

Failed to connect to mailserver at "localhost" port 25,
verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

Così, ho controllato php.ini

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25;

;Add X-PHP-Originating-Script: that will 
;include uid of the script followed by the filename

Ok, così ho pensato, "Ti basta usare il PHPMailer per includere lo SMTP e la porta:

require_once('../class.phpmailer.php');

$mail             = new PHPMailer();        // defaults to using php "mail()";

$body             = file_get_contents('contents.html');
$body             = eregi_replace("[\]",'',$body);

$mail->IsSMTP();                            // telling the class to use SMTP
$mail->AddReplyTo("noreply@randomcompany.com","Company Name Here");
$mail->Host       = "localhost";           // SMTP server
$mail->SMTPDebug  = 2;                      // enables SMTP debug information (for testing)
$mail->Port       = 25;                     // set the SMTP port for the GMAIL server


$mail->From       = "noreply@randomcompany.com";
$mail->FromName   = "Company Name Here";

$address = "test@yahoo.com";
$mail->AddAddress($address, "Hello to myself for testing!");

$mail->Subject    = "PHPMailer Test Subject via mail(), basic";

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

//$mail->AddAttachment("images/phpmailer.gif");      // attachment
//$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}

mail.add_x_header = Off 

che diceva:

SMTP -> ERROR: Failed to connect to server: 
A connection attempt failed because the connected 
party did not properly respond after a period of 
time, or established connection failed because 
connected host has failed to respond. (10060)

SMTP Error: Could not connect to SMTP host. 
Mailer Error: SMTP Error: Could not connect to SMTP host.

Mercury detto:

This message is sending now ...

Error! The message was not successfully sent!

Zurück zum Formular

trascorso tutto quel tempo e mi chiedo ora, è il mio codice, php.ini, la phpmailer, o Yahoo?

È stato utile?

Soluzione

Credo che vi state perdendo un server di posta. O avete un server di posta locale in esecuzione a porta 25? ;-) Ma XAMPP porta un server di posta con sé nome Mercury - così ... avviarlo e divertirsi; -).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top