我已经在我的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";
}
?>我使用html表单来获取发送电子邮件所需的参数。以下是我在发送电子邮件时遇到的错误。
C:\WebLearn\Apache-2.2\htdocs\SimpleWebsite\contact.php警告:邮件() function.mail:未能连接到"localhost“端口25的邮件服务器,在php.ini中验证"SMTP”和"smtp_port“设置,或在第7行使用ini_set()
我是否需要在php.ini文件或httpd.conf中设置任何设置?如果是,如何配置?我需要在我的电脑上额外的SMTP服务器来发送电子邮件吗?请建议从我的本地个人电脑发送电子邮件的必要步骤。
发布于 2012-01-22 07:32:12
这条信息是说,它正试图将这封电子邮件发送给本地主机:25,那里没有人在监听。
PHP不能直接给“Internet”发电子邮件。消息必须转到邮件服务器程序,如Postfix、Sendmail或SSMTP,然后SSMTP将其中继到适当的目的地。
您必须安装和配置邮件服务器程序,并通过php.ini设置PHP来使用它。我相信您还可以选择配置PHP来使用Sendmail二进制文件,而不是SMTP传递。
https://stackoverflow.com/questions/8959689
复制相似问题