我在Windows 7 PC上安装了Apache和PHP.我现在正在学习PHP.以下是我发送电子邮件的PHP脚本.
<?php
if(isset($_REQUEST['email']))
{
$email = $_REQUEST['email'];
$subject = $_REQUEST['subject'];
$message = $_REQUEST['message'];
mail("padhy.surya@gmail.com","$subject","$message","From:","$email");
echo "Thank you for using the email !!!";
}
else
{
echo "Mail is not set properly. Please fill the form properly";
}
?>
Run Code Online (Sandbox Code Playgroud)
我使用html表单来获取发送电子邮件所需的参数.以下是我发送电子邮件时收到的错误.
警告:mail()[function.mail]:无法连接到"localhost"端口25的邮件服务器,验证php.ini中的"SMTP"和"smtp_port"设置,或者在C:\ WebLearn\Apache-中使用ini_set()第7行的2.2\htdocs\SimpleWebsite\contact.php
我需要在php.ini文件或httpd.conf中设置任何设置吗?如果是,如何配置?我的PC上是否需要额外的SMTP服务器才能发送电子邮件?请建议从我的本地PC发送电子邮件的必要步骤.
消息是说它正在尝试将电子邮件发送到localhost:25,并且那里没有任何内容.
PHP无法直接通过电子邮件发送"Internet".该消息必须转到邮件服务器程序,如Postfix或Sendmail或SSMTP,然后将其中继到适当的目标.
您必须安装和配置邮件服务器程序并设置PHP以通过php.ini使用它.我相信您也可以选择配置PHP以使用Sendmail二进制文件而不是SMTP传递.
归档时间: |
|
查看次数: |
15960 次 |
最近记录: |