简体   繁体   English

将带有SMTP服务器的电子邮件PHP发送到Windows Server 2008

[英]Send an email PHP with SMTP server to Windows Server 2008

I would like to send an email from my PHP application. 我想从我的PHP应用程序发送电子邮件。 For this, I set up my website in IIS on my Windows server 2008. Can I install the Windows SMTP server. 为此,我在Windows服务器2008上的IIS中设置了我的网站。是否可以安装Windows SMTP服务器。

Then I create a test page to send an email: 然后,我创建一个测试页以发送电子邮件:

<?php
  Ini_set ('SMTP', 'localhost');
  Ini_set ('sendmail_from', 'myEmailTest@local.com');

  $to = 'myEmailTest@ExternalDomain.com';
  $subject = 'Example subject';
  $body = 'body ... With an example';

  if(mail($to, $subject, $body)){
     echo "Successful";
  }else{
     echo "Error";
  }
?>

I also configure php.ini and SMTP E-mail in IIS like this: 我还像这样在IIS中配置php.ini和SMTP电子邮件:

[Mail function]
smtp = localhost
smtp_port = 25

Then I test sending my mail. 然后,我测试发送我的邮件。 When I send the email to an email address of the local domain to another email address in the local domain. 当我将电子邮件发送到本地域的电子邮件地址时,将电子邮件发送到本地域中的另一个电子邮件地址。 Me back my page "Successful" and the email goes in the folder : 我返回页面“成功”,电子邮件进入文件夹:

C:\inetpub\mailroot\Drop

By cons, if I send an email from an email address in the local domain email address to an external domain (@ hotmail.com). 通过缺点,如果我将本地域电子邮件地址中的电子邮件地址中的电子邮件发送到外部域(@ hotmail.com)。 Me my page returns "Error" and nothing happens. 我的页面返回“错误”,但没有任何反应。

I look at the log files of my SMTP server, but there is no error message. 我查看了SMTP服务器的日志文件,但是没有错误消息。

Can you help me? 你能帮助我吗?

I successfully advanced a step. 我成功地前进了一步。 Now, when I send an email from an e-mail address of local domain to a e-mail address of an external domain (@hotmail.com), the mail is send to my PHP page, it gets stuck in against in the queue C:\\inetpub\\mailroot\\Queue . 现在,当我将电子邮件从本地域的电子邮件地址发送到外部域的电子邮件地址(@ hotmail.com)时,该邮件将发送到我的PHP页面,它被卡在队列中C:\\inetpub\\mailroot\\Queue

Does anyone know what is the problem? 有谁知道这是什么问题?

Thank you 谢谢

If your page is returning with an error (most likely a 500) then you need to have a look at the PHP error logs which are separate from the SMTP error logs. 如果您的页面返回错误(很可能是500),那么您需要查看与SMTP错误日志分开的PHP错误日志。 Please let us know what you find, as any error encountered while attempting to execute the php mail function, will show up in those logs. 请让我们知道您的发现,因为尝试执行php邮件功能时遇到的任何错误都会显示在这些日志中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM