从本地服务器发送我有我的文件mail.php:电子邮件在PHP
<html>
<body>
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("[email protected]", $subject,
$message, "From:" . $email);
echo "Thank you for using our mail form";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mail.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}
?>
</body>
</html>
,但是当我运行它。我得到这个错误:
Warning: mail() [function.mail]: Failed to connect to mailserver at "127.0.0.1" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files\EasyPHP-5.3.8.1\www\safepay247\mail.php on line 13
Thank you for using our mail form
什么即时试图做的是发邮件到我的邮箱ID:[email protected]使用PHP写在输入型的人的电子邮件。
我经历了许多视频,但没有任何帮助我解决php.ini问题。
你通常不希望从开发服务器发送邮件 - 如果它是从一个发送它不会在大多数情况下抵达动态IP。你有什么样的服务器?谁在管理它? – 2012-03-11 23:45:20
@皮卡 - 我使用easyPHP作为我的本地服务器。 – Samir 2012-03-11 23:46:52
我会推荐使用swiftmailer(http:// swiftmailer。org /)而不是mail()函数。在你的情况下,你的错误的原因是你没有在'php.ini'中设置有效的SMTP服务器。 – F21 2012-03-11 23:47:04