2011-07-27 35 views
5

Possible Duplicate:
php mail() function on localhostYardım

sitemde şifre kurtarma için bazı localhost test yapmaya çalışıyor, ama değilim ben bir e-posta göndermeye çalıştığınızda, aşağıdaki hatayı alıyorum:

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

İşte php.ini dosyasındaki ilgili ayarlar.

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

; For Win32 only. 
; http://php.net/sendmail-from 
sendmail_from = [email protected] 

Bunların localhost sınaması için ayarlanacağından emin değilim. Sağlayıcımın posta sunucusu ne olursa olsun SMTP'u ayarlamam gerektiğini anlıyorum, ama paylaşılan bir ofis binasında çalışıyorum, bu yüzden interneti kimin temin ettiğini bile öğrenemiyorum.

Şimdiden teşekkürler.

cevap

2

PHP'nin postasının çalışması için yerel bir e-posta sunucusu gerekiyor.

Düzenleme: mail() için PHP dokümantasyon sitesi ortaya çıktığında, PEAR'dan bir Posta paketi kullanabilirsiniz.

+0

... ya da İSS birini kullanabilirsiniz:

PHPMailer örnek:Bu PHP kütüphaneleri aslında çok kolayca aynı makinede yüklü e-posta sunucusu olmadan, herhangi bir platformdan e-posta gönderebilirsiniz SMTP protokolünü uygulamak. – Shef

7

PHP'nin mail() fonksiyonu doğrudan SMTP protokolünü uygulamıyor. Bunun yerine, sendmail() MTA (SMTP sunucusu) veya postfix veya mstmp gibi bir yedeğe dayanır. MTA kurulu olduğu sürece Unix'te iyi çalışıyor.

Windows'ta (php.net dan manuel): Yani

The Windows implementation of mail() differs in many ways from the Unix implementation. First, it doesn't use a local binary for composing messages but only operates on direct sockets which means a MTA is needed listening on a network socket (which can either on the localhost or a remote machine).

- Hikayenin özü - Eğer posta sunucusu yüklemeniz gerekir.

Ancak - Test amaçlı olmadığını, sadece - sadece aslında SMTP protokolünü uygulayan bir PHP kütüphanesi olsun ve e-posta göndermek için normal gmail e-posta adresini kullanabilirsiniz: Bunlardan birini kullanın) (PHP'nin posta kullanan

yerine:

  1. PHPMailer
  2. SwiftMailer
  3. Zend \ Posta
$mail->IsSMTP(); // telling the class to use SMTP 
$mail->Host  = "stmp.gmail.com"; // SMTP server 
$mail->SMTPDebug = 1;      // enables SMTP debug information (for testing) 
// 1 = errors and messages 
// 2 = messages only 
$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 = "pass111";   // GMAIL password 
$mail->SetFrom('[email protected]', 'My name is slim shady'); 
$mail->AddReplyTo("[email protected]","My name is slim shady"); 
$mail->Subject = "Hey, check out http://www.site.com"; 
$mail->AltBody = "Hey, check out this new post on www.site.com"; // optional, comment out and test 
$mail->MsgHTML($body); 
$address = "[email protected]"; 
$mail->AddAddress($address, "My name is slim shady");