我在使用 php mail() 函数发送电子邮件时遇到问题。我知道我拥有的 php 脚本可以工作,因为我在另一家网络托管公司有一个相同的副本,并且它在那里工作。
我认为这与网络托管公司本身有关。你们中有人知道我需要做什么才能使其正常工作吗?我需要告诉他们安装什么吗?我认为他们在 Apache 上运行。
谢谢,阿米特
为澄清起见,这里是邮件脚本。
<?php
$to = 'my@email.com';
$subject = 'Contact from your website';
$message =
'Below are details from the Contact Us Form ' . "\n\n" .
'Name: ' . $_REQUEST['name'] . "\n\n" .
'Telephone Number: ' . $_REQUEST['phone'] . "\n\n" .
'E-mail address: ' . $_REQUEST['email'] . "\n\n" .
'Comments: ' . $_REQUEST['comments'];
$email = $_REQUEST['email'];
$headers = 'From: ' . $email . "\r\n" .
'Reply-To: ' . $email . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/plain; charset=ISO-8859-1";
//SPAM CHECK
$str = $_REQUEST['spam'];
$strE = $_REQUEST['email'];
if( $str != "10" || $strE == "")
{
echo "<div align='center' style='color:red'>One or more of the form fields were incorrect, you will be redirected to the contact page within 3 seconds.</div>";
?><meta http-equiv="refresh" content="3;URL=http://engineercreativity.com/samples/biz/contact"><!-- EDIT THIS -->
<?php
} else {
mail ($to, $subject, $message, $headers);
?>
<meta http-equiv="refresh" content="0;URL=http://engineercreativity.com/thankyou.html"> <!-- EDIT THIS AS WELL -->
<!--
<div class="text" align="center" style="text-align: center; color: green;">
<br/>
Thank you for contacting us!
<br/>
The message was succesfully sent!
</div>
-->
<?php
}
?>