고객이 보일러 서비스를 예약 할 수 있도록 양식이 웹 사이트에 있습니다. 최근까지는 작동했지만 웹 호스트는 스팸 필터를 변경했습니다. 스크립트는 서버에서 양식 데이터를 전송했지만 이제는 SMTP 서버에서 보내야합니다. 나는이 일을 며칠 동안 어지럽게 해왔다.SMTP 이메일에서 PHP 양식 데이터를 보내려면 어떻게해야합니까?
이것은 내 양식 코드입니다.
<form name="freecontactform" method="post" action="freecontactformprocess.php" onsubmit = "return validate.check(this)">
<table width="400px" class="freecontactform">
<tr>
<td colspan="2">
<div class="freecontactformheader">Boiler Service Form</div>
<div class="freecontactformmessage">Fields marked with <span class="required_star"> * </span> are mandatory.</div>
</td>
</tr>
<tr>
<td valign="top">
<label for="Full_Name" class="required">Full Name<span class="required_star"> * </span></label>
</td>
<td valign="top">
<input type="text" name="Full_Name" id="Full_Name" maxlength="80" style="width:230px">
</td>
</tr>
<tr>
<td valign="top">
<label for="Address" class="required">Address<span class="required_star"> * </span></label>
</td>
<td valign="top">
<input type="text" name="Address" id="Address" maxlength="100" style="width:230px">
</td>
</tr>
<tr>
<td valign="top">
<label for="postcode" class="not-required">Post Code</label>
</td>
<td valign="top">
<input type="text" name="postcode" id="postcode" maxlength="100" style="width:230px">
</td>
</tr>
<tr>
<td valign="top">
<label for="email" class="not-required">Email Address</label>
</td>
<td valign="top">
<input type="text" name="email" id="email" maxlength="100" style="width:230px">
</td>
<tr>
<td valign="top">
<label for="Telephone_Number" class="not-required">Telephone Number</label>
</td>
<td valign="top">
<input type="text" name="Telephone_Number" id="Telephone_Number" maxlength="100" style="width:230px">
</td>
<tr>
<td valign="top">
<label for="Payment" class="not-required">Payment</label>
</td>
<td valign="top"><p>
<input type="radio" name="payment" value="redirect.html"/>
Pay Online Via PayPal<br />
<input type="radio" name="payment" value="thankyou.html"/>
Card/Cash/Cheque on Day<br />
</p></td>
</tr>
<tr>
<td colspan="2" style="text-align:center" >
<div class="antispammessage">
To help prevent automated spam, please answer this question
<br /><br />
<div class="antispamquestion">
<span class="required_star"> * </span>
Using only numbers, what is 10 plus 15?
<input type="text" name="AntiSpam" id="AntiSpam" maxlength="100" style="width:30px">
</div>
</div>
</td>
</tr>
<tr>
<td colspan="2" style="text-align:center" >
<br /><br />
<input type="submit" value=" Submit Form " style="width:200px;height:40px">
<br /><br />
<br /><br />
</td>
</tr>
</table>
</form>
이
내 PHP 나는 내 웹 호스트에서 사용하는 이메일로 보낼 필요가<?php
if(isset($_POST['email'])) {
include 'freecontactformsettings.php';
function died($error) {
echo "Sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
if(!isset($_POST['Full_Name']) ||
!isset($_POST['Address']) ||
!isset($_POST['postcode']) ||
!isset($_POST['email']) ||
!isset($_POST['Telephone_Number']) ||
!isset($_POST['payment']) ||
!isset($_POST['AntiSpam'])
) {
died('Sorry, there appears to be a problem with your form submission.');
}
$full_name = $_POST['Full_Name']; // required
$address = $_POST['Address']; // required
$postcode = $_POST['postcode']; // not required
$email = $_POST['email']; // not required
$telephone = $_POST['Telephone_Number']; // not required
$payment = $_POST['payment']; // required
$antispam = $_POST['AntiSpam']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-][email protected][A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(preg_match($email_exp,$email)==0) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
if(strlen($full_name) < 2) {
$error_message .= 'Your Name does not appear to be valid.<br />';
}
if($antispam <> $antispam_answer) {
$error_message .= 'The Anti-Spam answer you entered is not correct.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\r\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:");
return str_replace($bad,"",$string);
}
$email_message .= "".clean_string($full_name)."\r\n";
$email_message .= "".clean_string($address)."\r\n";
$email_message .= "".clean_string($postcode)."\r\n";
$email_message .= "".clean_string($email_from)."\r\n";
$email_message .= "".clean_string($telephone)."\r\n";
$email_message .= "".clean_string($payment)."\r\n";
$headers = "From: [email protected]";
$headers = 'Reply-To: '.$email."\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($headers, $email_to, $email_subject, $email_message);
?>
<?php
$payment = $_POST['payment'];
if (!empty($payment))
header('Location: '.$payment) ;
}
die();
?>
입니다, 그것은 SMTP 서버입니다.
은 SMTP 서버를 통해 보내려면 미리
http://www.9lessons.info/2009/10/send-mail-using-smtp-and-php.html – BenM
이것은 내가 무엇을했는지, 감사합니다. – user1627327
도와 줘서 다행입니다. 유용하다고 생각하면 대답으로 추가했습니다. – BenM