简体   繁体   English

如何在XAMPP中配置php邮件

[英]How to configure php mail in XAMPP

I am using Windows Server 2008 R2. 我使用的是Windows Server 2008 R2。 I have installed XAMPP which installed MySQL, PHP, and Apache. 我安装了安装MySQL,PHP和Apache的XAMPP。 I also installed WordPress. 我还安装了WordPress。 I have a couple questions that I can't seem to get a straight answer by searching Google. 我有几个问题,我似乎无法通过搜索谷歌获得直接的答案。 I've been searching for these answers for over 8 hours. 我一直在寻找这些答案超过8小时。

Questions 问题

  1. Is there a way to install an SMTP server to work with Apache? 有没有办法安装SMTP服务器以使用Apache? If so, how? 如果是这样,怎么样?

  2. Can I configure php mail to work without using SMTP? 我可以配置php邮件不使用SMTP吗? If so, how? 如果是这样,怎么样?

Problem: 问题:

I have configured the mail in WordPress and the sendmail.ini. 我已经在WordPress和sendmail.ini中配置了邮件。 I can send a test email and it says it is sent, but I never receive the email. 我可以发送测试电子邮件,并说它已发送,但我从未收到过该电子邮件。 I really need help getting this fixed. 我真的需要帮助解决这个问题。 I'm totally at a loss. 我完全不知所措。

Send Mail output below 发送邮件输出如下

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

Below is the code to the sendmail.ini - I'm not sure this was configured correctly 下面是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

Question 1: Is there a way to install an SMTP server to work with Apache? 问题1:有没有办法安装SMTP服务器以使用Apache? If so, how? 如果是这样,怎么样?

As Devon mentioned in your comments, SMTP and Apache are different servers/services and use different protocols all together. 正如Devon在您的评论中提到的,SMTP和Apache是​​不同的服务器/服务,并且一起使用不同的协议。 From what I can understand from your question, Yes you can setup the built in SMTP server on your 2008 R2 server and use it to send mail as long as you have a static IP from your ISP where the server resides (if you have a dynamic IP where your server is your IP may be permanently blocked from being able to send to anybody but a local mail server which in your case would be either a exchange server or a 3rd party email application in which would only reside locally for testing purposes). 根据您的问题我可以理解,是的,您可以在2008 R2服务器上设置内置SMTP服务器,并使用它来发送邮件,只要您有来自服务器所在ISP的静态IP(如果您有动态)您的服务器所在IP的IP可能会永久阻止发送给任何人,但本地邮件服务器在您的情况下可能是交换服务器或第三方电子邮件应用程序,其中只存在于本地用于测试目的)。 If you really want to know what is happening to your email I would follow this link on getting your SMTP logs setup and viewing what is really happening to the mail that is sent through PHP. 如果你真的想知道你的电子邮件发生了什么,我会按照这个链接获取你的SMTP日志设置,并查看通过PHP发送的邮件真正发生的事情。

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

Also on a side note, if you are using the PHP mail function or any type of mail function (not just PHP) typically you would not use SSL on port 25 unless you configured SMTP to use SMTP over SSL in that manner (The settings you have setup on the plugin does not really make sense). 另外在旁注中,如果您使用PHP邮件功能或任何类型的邮件功能(不仅仅是PHP),通常您不会在端口25上使用SSL,除非您将SMTP配置为以这种方式使用SMTP over SSL(设置为在插件上设置并没有多大意义)。

Question 2: Can I configure php mail to work without using SMTP? 问题2:我可以配置php邮件而不使用SMTP吗? If so, how? 如果是这样,怎么样?

The plugin you are using has the ability for you to not send to a localhost (Local SMTP server) but rather another address like gmail, yahoo, secureserver (godaddy) or any other mail service provider which would be SMTP for your particular situation. 您使用的插件可以让您不发送到本地主机(本地SMTP服务器),而是发送另一个地址,如gmail,yahoo,secureserver(godaddy)或任何其他邮件服务提供商,它们将是您的特定情况的SMTP。 Depending on the provider the SMTP configuration will change based on the setup that you have for the account. 根据提供程序,SMTP配置将根据您对该帐户的设置进行更改。

Here is a brief list of servers that you could use instead of localhost and you would require SMTP authentication (which requires an account with one of them). 以下是您可以使用的服务器的简短列表,而不是localhost,您需要SMTP身份验证(这需要一个帐户,其中一个帐户)。

http://www.arclab.com/en/amlc/list-of-smtp-and-pop3-servers-mailserver-list.html 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