Comment puis-je envoyer mon PHP des données de formulaire d'e-mail SMTP
j'ai un formulaire sur mon site web afin que les clients peuvent réserver une Chaudière de service. Jusqu'à récemment, il était au travail, mais mon hébergeur a changé il y a les filtres anti-spam. Le script a été l'envoi du formulaire de données à partir du serveur, mais j'ai maintenant besoin de l'envoyer à partir du serveur smtp. J'ai été déconner avec cette pendant des jours, toute aide serait appréciée.
C'est mon code du Formulaire.
<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>
C'est mon 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._%-]+@[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();
?>
J'ai besoin de l'envoyer à partir de l'email que j'ai avec mon hébergeur, c'est un serveur SMTP.
Je vous remercie à l'avance
- 9lessons.info/2009/10/send-mail-using-smtp-and-php.html
- c'est ce que je recherchais, merci
- Ravi de vous aider. Je l'ai ajouté comme une réponse si vous pouvez l'accepter si c'était utile.
Vous devez vous connecter pour publier un commentaire.
Vous pourriez vouloir vérifier cette pratique de l'Article:
http://www.9lessons.info/2009/10/send-mail-using-smtp-and-php.html
À envoyer via un serveur SMTP, vous aurez besoin d'utiliser un mail de script tels que PHPMailer. Pour un débutant tutoriel, voir ici.