我的联系页面上有一个联系表格,它是一个 php 页面。我正在收集用户的请求并尝试将其邮寄到 me@mydomain.com。但是,我尝试了所有不同的方式,但无法使用 php 发送邮件。我对 php 很陌生,我正在努力学习这门语言。这是代码示例。
这是我的 HTML
<h2>Your Details</h2></br>
<div class="form_row">
<input type="text" class="form_input" name="name" id="txtName" placeholder="Your Name" />
</div>
<div class="form_row">
<input type="text" class="form_input" name="phone" id="txtPhone" placeholder="Phone Number" />
</div>
<div class="form_row">
<input type="text" class="form_input" name="email" id="txtEmail" placeholder="Email" />
</div>
<div class="form_row">
<textarea class="form_textarea" name="message" id="txtMessage" placeholder="Provide as much information you can regarding the project."></textarea>
<p><input type="submit" id="submit" class="button" value="Send"/></p>
</div>
这是我的 php 脚本
<?php
if(isset($_POST['submit']))
{
$to = "harish.upadhyayula@ritchsystems.com";
$subject = 'Request for quote from - ritch systems website.';
$from = 'Surekha';
$phone = '410-555-4988';
$message = 'Testing php mail by hard coding.';
$headers = "From: ".$from."\r\n" .
"Phone: ".$phone;
ini_set("sendmail_from", $from);
if(mail( $to, $subject, $message, $headers ))
{
echo 'Mail Sent';
}
else {echo 'Something is wrong!';}
}
?>