为什么这个短的php脚本不发送电子邮件? [英] Why doesn't this short php script send email?

查看:135
本文介绍了为什么这个短的php脚本不发送电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看不到我的php脚本发送电子邮件。

 <?php 
echo 这个页面是否有效?
mail('我的电子邮件地址','测试主题','测试消息');
?>

首先,我已经在php.ini文件中设置了邮件功能设置,如下所示:



我查看了我的电子邮件帐户设置。它不需要身份验证,其端口为25,加密连接类型为自动。鉴于此,我相应地配置了我的php.ini文件:

  SMTP = ssl://smtp1.iis.com 
smtp_port = 25

然后我设置:

  sendmail_from =我的电子邮件地址

echo语句打印出来浏览器,所以我知道php文件被识别和处理。但浏览器还显示以下错误:

 警告:mail()[function.mail]:sendmail_from未设置在C:\xampp\htdocs\mailtest.php第3行缺少php.ini或自定义From:标题

我已经清楚地设置了sendmail_from,所以我不知道还有什么要做的。我也尝试从php.ini文件中的SMTP设置中删除'ssl://'部分,并配置php5.ini文件。我应该配置哪些.ini文件?

解决方案

我现在有一个答案我的问题...

我用phpinfo()找出我应该编辑哪个php.ini文件。事实证明,我的服务器文件夹中有3个这样的文件可用。两个在PhP文件夹下(分别命名为php.ini和php5.in),另一个在apache / bin文件夹中。使用phpinfo()函数,我能够确定我正在编辑错误的.ini文件(我查看了我正在设置的参数,而且没有改变)。一旦我编辑正确的(在apache / bin中)警告:mail()[function.mail]:sendmail_from...错误停止发生。



然后,为了发送邮件,我编辑了正确的.ini文件,原来是在我的问题上提出的:

  SMTP = myoutgoingmail .com(与我的邮件程序相同的设置 -  outlook)
smtp_port =(和我的邮件程序一样 - oultook)

sendmail_from = myemailaddress.com


I can't seem to get my php script to send email.

<?php 
echo "Does this page work?";
mail('my email address', 'test subject', 'test message');
?>

First, I have set the mail function settings in the php.ini file as follows:

I checked my email account settings on outlook. It does not require authentication, its port is 25, and its type of encrypted connection is 'Auto'. Given this I configured my php.ini file accordingly:

SMTP = ssl://smtp1.iis.com
smtp_port = 25

Then I set:

sendmail_from = my email address

The echo statement prints out in the browser, so I know the php file is recognized and processed. But the browser also shows the following error:

Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs\mailtest.php on line 3

I have clearly set the sendmail_from so I don't know what else to do. I have also tried removing the 'ssl://' part from the SMTP setting in the php.ini file, and configuring the php5.ini file. Which of these .ini files should I be configuring anyways?

解决方案

I now have an ANSWER to my question...

I used phpinfo() to find out which php.ini file I was supposed to be editing. As it turned out, there were 3 such files available in my server folder. Two were under the PhP folder (named php.ini and php5.in respectively) and the other was in the apache/bin folder. Using the phpinfo() function, I was able to determine that I was editing the wrong .ini files (I looked at the parameters I was setting and the were not changing). Once I edited the correct one (the one in apache/bin) the Warning: mail() [function.mail]: "sendmail_from"...error stopped occurring.

Then, to get the mail sent, I edited the correct .ini file as originally posed in my question:

SMTP = myoutgoingmail.com (the same setting as my mail program - outlook)
smtp_port = (the same as my mail program - oultook)

sendmail_from = myemailaddress.com

这篇关于为什么这个短的php脚本不发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆