簡體   English   中英

如何使用PHP從本地Wamp服務器發送電子郵件?

[英]How to send email from local wamp server using PHP?

我需要從本地主機發送電子郵件。

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

默認情況下,mail()函數通常不適用於WAMP之類的東西。 您將需要將SMTP服務器的詳細信息添加到php.ini文件中。

這是一個很好的教程: http : //roshanbh.com.np/2007/12/sending-e-mail-from-localhost-in-php-in-windows-environment.html

這是實現此目的的步驟:

  • 通過此鏈接下載sendmail.zip

    • 現在,解壓縮該文件夾並將其放入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 =錯誤日志
    • debug_logfile = debug.log
    • auth_username = [您的gmail_帳戶_用戶名] @ gmail.com
    • auth_password = [您的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 = you@domain.com ; 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 Server

希望這對您有用。

打開您的php.ini並找到[郵件功能]部分

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

更改設置:

SMTP = ; Enter here the address of your SMTP server
smtp_port = 25

最后,從PHP腳本開始,您必須使用郵件功能http://php.net/manual/en/function.mail.php

您可以在PHP中使用mail函數。 http://php.net/manual/zh/function.mail.php

當您自己托管它時,您必須檢查您的互聯網提供商smtp並使用它更新php.ini,這應該可以工作。

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

  • SMTP
  • smtp_port
  • sendmail_from
  • sendmail_path

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM