2012-05-21 25 views
0

我正在嘗試使用xampp在本地計算機(Windows 7)中運行PHP郵件腳本。我能成功運行的PHP郵件的形式,但在發送的電子郵件就說明這個MESSAGE-如何在Windows 7中運行PHP郵件腳本?

**Warning: mail() [function.mail]: SMTP server response: 553 We do not relay non-local mail, sorry. in C:\xampp\htdocs\mail\sendeail.php on line 146** 

如何解決這個問題,或者是否有可能從我的本地計算機使用XAMPP發送電子郵件任何其他方式?

+4

此錯誤消息是由您的郵件服務器,而不是由PHP生成。很可能,這表示您在php.ini中將SMTP服務器設置錯誤。 – duskwuff

回答

0

觀看如此多的YouTube視頻和博客之後,這是對我工作:

  1. 確保您的SMTP服務狀態顯示已激活 - >去this URL得到一個不錯的演示。

  2. 轉到this URL,使用您用來測試您的php電子郵件的gmail帳戶登錄,然後在安全選項卡中找到「訪問不太安全的應用程序」,然後單擊啓用(您可以再次禁用它在您的PHP電子郵件測試後)。

  3. 從一個全新的php.ini文件開始(希望你做了一個你的orignal php.ini的副本)。原因是這樣你會有一個沒有被篡改的php.ini。在php.ini以下這些行必須是評論(擁有國內領先的;)或註釋掉(沒有領先;),這是至關重要的):

    [mail function] 
    ; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury 
    ;SMTP = localhost 
    ;smtp_port = 25 
    
    sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" 
    
    ;sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe" 
    
    extension=php_openssl.dll 
    

    一切都在php.ini YOU先不談別的。

    讓我們仔細檢查這些行加以註釋(擁有國內領先的;):

    ;SMTP= local host 
    ;smtp_port = 25 
    ;sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe" 
    
  4. 然後sendmail.ini必須如下 - 我這裏基本上覆制了整個事情。它說:your.email.gmail鍵入自己的Gmail地址,同樣的事情,密碼爲:

    [sendmail] 
    ; you must change mail.mydomain.com to your smtp server, 
    ; or to IIS's "pickup" directory. (generally C:\Inetpub\mailroot\Pickup) 
    ; emails delivered via IIS's pickup directory cause sendmail to 
    ; run quicker, but you won't get error messages back to the calling 
    ; application. 
    
    smtp_server=smtp.gmail.com 
    
    ; smtp port (normally 25) 
    
    smtp_port=465 
    
    ; SMTPS (SSL) support 
    ; auto = use SSL for port 465, otherwise try to use TLS 
    ; ssl = alway use SSL 
    ; tls = always use TLS 
    ; none = never try to use SSL 
    
    smtp_ssl=auto 
    
    ; the default domain for this server will be read from the registry 
    ; this will be appended to email addresses when one isn't provided 
    ; if you want to override the value in the registry, uncomment and modify 
    
    ;default_domain=mydomain.com 
    
    ; log smtp errors to error.log (defaults to same directory as sendmail.exe) 
    ; uncomment to enable logging 
    
    error_logfile=error.log 
    
    ; create debug log as debug.log (defaults to same directory as sendmail.exe) 
    ; uncomment to enable debugging 
    
    ;debug_logfile=debug.log 
    
    ; if your smtp server requires authentication, modify the following two lines 
    
    [email protected] 
    auth_password=your email password 
    
    ; if your smtp server uses pop3 before smtp authentication, modify the 
    ; following three lines. do not enable unless it is required. 
    
    pop3_server= 
    pop3_username= 
    pop3_password= 
    
    ; force the sender to always be the following email address 
    ; this will only affect the "MAIL FROM" command, it won't modify 
    ; the "From: " header of the message content 
    
    force_sender= 
    
    ; force the sender to always be the following email address 
    ; this will only affect the "RCTP TO" command, it won't modify 
    ; the "To: " header of the message content 
    
    force_recipient= 
    
    ; sendmail will use your hostname and your default_domain in the ehlo/helo 
    ; smtp greeting. you can manually set the ehlo/helo name if required 
    
    hostname=