【发布时间】:2017-02-04 13:28:57
【问题描述】:
我在 php 中使用简单的发送电子邮件并收到此错误
警告:mail() [function.mail]:无法连接到邮件服务器 “localhost”端口 587,验证您的“SMTP”和“smtp_port”设置 php.ini 或使用 ini_set() in
<?php
//if "email" variable is filled out, send email
if (isset($_REQUEST['email'])) {
//Email information
$admin_email = "Silicon.abhishekp@gmail.com";
$email = $_REQUEST['email'];
$subject = $_REQUEST['subject'];
$comment = $_REQUEST['comment'];
//send email
mail($admin_email, "$subject", $comment, "From:" . $email);
//Email response
echo "Thank you for contacting us!";
}
//if "email" variable is not filled out, display the form
else {
?>
<form method="post">
Email: <input name="email" type="text" /><br />
Subject: <input name="subject" type="text" /><br />
Message:<br />
<textarea name="comment" rows="15" cols="40"></textarea><br />
<input type="submit" value="Submit" />
</form>
<?php
}
?>
【问题讨论】:
标签: php email html-email