2011-10-19 92 views
26

我需要從我的本地主機發送電子郵件。如何使用PHP從本地wamp服務器發送電子郵件?

我正在使用wamp服務器,我的網站已加載到我自己的服務器上,請問您可以建議如何使用我的本地主機和PHP發送電子郵件?

+0

你可能需要的東西等配置的SMTP客戶端在背景中。也許sendmail或類似的東西... –

+0

閱讀這個帖子http://roshanbh.com.np/2007/12/sending-e-mail-from-localhost-in-php-in-windows-environment.html – Gowri

+0

possible [如何配置WAMP(localhost)使用Gmail發送電子郵件的副本?](http://stackoverflow.com/questions/600725/how-to-configure-wamp-localhost-to-send-email-using-gmail) – mario

回答

0

在php.ini,設置以下參數:

  • SMTP
  • SMTP_PORT
  • sendmail_from
  • sendmail_path
2

打開你的p hp.ini並找到[郵件功能]部分

之後,您必須更改以下選項並與SMTP設置相關。

設置改變:

SMTP = ; Enter here the address of your SMTP server 
smtp_port = 25 
從你的PHP腳本

Finaly你必須使用郵件功能http://php.net/manual/en/function.mail.php

3

這裏的步驟來實現這一目標:

  • 下載sendmail.zip通過這個link

    • 現在,解壓縮文件夾並將其放到C:/ wamp /中。確保這四個文件存在:sendmail.exe,libeay32.dll,ssleay32.ddl和sendmail.ini。
    • 打開sendmail.ini並設置配置如下:

    • smtp_server = smtp.gmail.com

    • SMTP_PORT = 465
    • smtp_ssl = SSL
    • DEFAULT_DOMAIN =本地主機
    • error_logfile = error.log
    • debug_logfile = debug.log
    • auth_username = [your_gmail_acc ount_username] @gmail。COM
    • AUTH_PASSWORD = [your_gmail_account_password]
    • pop3_server =
    • pop3_username =
    • pop3_password =
    • force_sender =
    • force_recipient =
    • 主機=本地主機

    • 訪問電子郵件帳戶。點擊齒輪工具>設置>轉發和POP/IMAP> IMAP訪問。點擊「啓用IMAP」,然後保存您的更改。

    • 運行你的WAMP服務器。在Apache模塊下啓用ssl_module。

    • 接下來,使PHP下php_openssl和php_sockets。

    • 打開php.ini並將其配置爲以下代碼。基本上,你只需要設置sendmail_path。

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

; For Win32 only. 
; http://php.net/sendmail-from 
;sendmail_from = [email protected] 
; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). 
; http://php.net/sendmail-path 
sendmail_path = "C:\wamp\sendmail\sendmail.exe -t -i" 
  • 重啓WAMP服務器

我希望這會爲你工作..

相關問題