簡體   English   中英

如何在XAMPP中配置php郵件

[英]How to configure php mail in XAMPP

我使用的是Windows Server 2008 R2。 我安裝了安裝MySQL,PHP和Apache的XAMPP。 我還安裝了WordPress。 我有幾個問題,我似乎無法通過搜索谷歌獲得直接的答案。 我一直在尋找這些答案超過8小時。

問題

  1. 有沒有辦法安裝SMTP服務器以使用Apache? 如果是這樣,怎么樣?

  2. 我可以配置php郵件不使用SMTP嗎? 如果是這樣,怎么樣?

問題:

我已經在WordPress和sendmail.ini中配置了郵件。 我可以發送測試電子郵件,並說它已發送,但我從未收到過該電子郵件。 我真的需要幫助解決這個問題。 我完全不知所措。

發送郵件輸出如下

Test Message Sent

The result was:

bool(true)

The full debugging output is shown below:

object(PHPMailer)#232 (65) {
  ["Priority"]=>
  int(3)
  ["CharSet"]=>
  string(5) "UTF-8"
  ["ContentType"]=>
  string(10) "text/plain"
  ["Encoding"]=>
  string(4) "8bit"
  ["ErrorInfo"]=>
  string(0) ""
  ["From"]=>
  string(23) "myemail@email.com"
  ["FromName"]=>
  string(12) "Joe Randolph"
  ["Sender"]=>
  string(23) "myemail@email.com"
  ["ReturnPath"]=>
  string(0) ""
  ["Subject"]=>
  string(50) "WP Mail SMTP: Test mail to myemail@email.com"
  ["Body"]=>
  string(68) "This is a test email generated by the WP Mail SMTP WordPress plugin."
  ["AltBody"]=>
  string(0) ""
  ["MIMEBody":protected]=>
  string(69) "This is a test email generated by the WP Mail SMTP WordPress plugin.
"
  ["MIMEHeader":protected]=>
  string(364) "Date: Wed, 9 Apr 2014 01:55:32 +0000
Return-Path: myemail@email.com
From: Joe Randolph 
Message-ID: <2c046a69376cf33b2ede557c0e3f3e8a@127.0.0.1>
X-Priority: 3
X-Mailer: PHPMailer 5.2.4 (http://code.google.com/a/apache-extras.org/p/phpmailer/)
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=UTF-8
"
  ["mailHeader":protected]=>
  string(88) "To: myemail@email.com
Subject: WP Mail SMTP: Test mail to myemail@email.com
"
  ["WordWrap"]=>
  int(0)
  ["Mailer"]=>
  string(4) "mail"
  ["Sendmail"]=>
  string(18) "/usr/sbin/sendmail"
  ["UseSendmailOptions"]=>
  bool(true)
  ["PluginDir"]=>
  string(0) ""
  ["ConfirmReadingTo"]=>
  string(0) ""
  ["Hostname"]=>
  string(0) ""
  ["MessageID"]=>
  string(0) ""
  ["MessageDate"]=>
  string(0) ""
  ["Host"]=>
  string(9) "localhost"
  ["Port"]=>
  int(25)
  ["Helo"]=>
  string(0) ""
  ["SMTPSecure"]=>
  string(3) "ssl"
  ["SMTPAuth"]=>
  bool(false)
  ["Username"]=>
  string(0) ""
  ["Password"]=>
  string(0) ""
  ["AuthType"]=>
  string(0) ""
  ["Realm"]=>
  string(0) ""
  ["Workstation"]=>
  string(0) ""
  ["Timeout"]=>
  int(10)
  ["SMTPDebug"]=>
  bool(true)
  ["Debugoutput"]=>
  string(4) "echo"
  ["SMTPKeepAlive"]=>
  bool(false)
  ["SingleTo"]=>
  bool(false)
  ["SingleToArray"]=>
  array(0) {
  }
  ["LE"]=>
  string(1) "
"
  ["DKIM_selector"]=>
  string(0) ""
  ["DKIM_identity"]=>
  string(0) ""
  ["DKIM_passphrase"]=>
  string(0) ""
  ["DKIM_domain"]=>
  string(0) ""
  ["DKIM_private"]=>
  string(0) ""
  ["action_function"]=>
  string(0) ""
  ["Version"]=>
  string(5) "5.2.4"
  ["XMailer"]=>
  string(0) ""
  ["smtp":protected]=>
  NULL
  ["to":protected]=>
  array(1) {
    [0]=>
    array(2) {
      [0]=>
      string(23) "myemail@email.com"
      [1]=>
      string(0) ""
    }
  }
  ["cc":protected]=>
  array(0) {
  }
  ["bcc":protected]=>
  array(0) {
  }
  ["ReplyTo":protected]=>
  array(0) {
  }
  ["all_recipients":protected]=>
  array(1) {
    ["myemail@email.com"]=>
    bool(true)
  }
  ["attachment":protected]=>
  array(0) {
  }
  ["CustomHeader":protected]=>
  array(0) {
  }
  ["message_type":protected]=>
  string(5) "plain"
  ["boundary":protected]=>
  array(3) {
    [1]=>
    string(35) "b1_2c046a69376cf33b2ede557c0e3f3e8a"
    [2]=>
    string(35) "b2_2c046a69376cf33b2ede557c0e3f3e8a"
    [3]=>
    string(35) "b3_2c046a69376cf33b2ede557c0e3f3e8a"
  }
  ["language":protected]=>
  array(0) {
  }
  ["error_count":protected]=>
  int(0)
  ["sign_cert_file":protected]=>
  string(0) ""
  ["sign_key_file":protected]=>
  string(0) ""
  ["sign_key_pass":protected]=>
  string(0) ""
  ["exceptions":protected]=>
  bool(true)
}

電子郵件配置截圖1

電子郵件配置截圖2

下面是sendmail.ini的代碼 - 我不確定這是否配置正確

; configuration for fake sendmail

; if this file doesn't exist, sendmail.exe will look for the settings in
; the registry, under HKLM\Software\Sendmail

[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=mail.localhost.com

; smtp port (normally 25)

smtp_port=25

; 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

auth_username=myemail@email.com 
auth_password=test1

; 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=localhost

問題1:有沒有辦法安裝SMTP服務器以使用Apache? 如果是這樣,怎么樣?

正如Devon在您的評論中提到的,SMTP和Apache是​​不同的服務器/服務,並且一起使用不同的協議。 根據您的問題我可以理解,是的,您可以在2008 R2服務器上設置內置SMTP服務器,並使用它來發送郵件,只要您有來自服務器所在ISP的靜態IP(如果您有動態)您的服務器所在IP的IP可能會永久阻止發送給任何人,但本地郵件服務器在您的情況下可能是交換服務器或第三方電子郵件應用程序,其中只存在於本地用於測試目的)。 如果你真的想知道你的電子郵件發生了什么,我會按照這個鏈接獲取你的SMTP日志設置,並查看通過PHP發送的郵件真正發生的事情。

http://www.vsysad.com/2012/04/setup-and-configure-smtp-server-on-windows-server-2008-r2/

另外在旁注中,如果您使用PHP郵件功能或任何類型的郵件功能(不僅僅是PHP),通常您不會在端口25上使用SSL,除非您將SMTP配置為以這種方式使用SMTP over SSL(設置為在插件上設置並沒有多大意義)。

問題2:我可以配置php郵件而不使用SMTP嗎? 如果是這樣,怎么樣?

您使用的插件可以讓您不發送到本地主機(本地SMTP服務器),而是發送另一個地址,如gmail,yahoo,secureserver(godaddy)或任何其他郵件服務提供商,它們將是您的特定情況的SMTP。 根據提供程序,SMTP配置將根據您對該帳戶的設置進行更改。

以下是您可以使用的服務器的簡短列表,而不是localhost,您需要SMTP身份驗證(這需要一個帳戶,其中一個帳戶)。

http://www.arclab.com/en/amlc/list-of-smtp-and-pop3-servers-mailserver-list.html

暫無
暫無

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

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