從本地服務器發送我有我的文件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