Problem PHP Mailer
I made an contact form using开发者_如何学Python PHP Mailer, the code is based on the PHPMailer test mail which worked fine.
But now it just won't send my email, it keeps showing me wrong. Instead of Verzonden (Sended)
Here's my code
<?php
require("CMS/scripts/phpmailer/phpmailer.inc.php");
if (isset($_POST) && !empty($_POST) && $_POST['post_form'] == "contact") {
$mail = new phpmailer;
print_pre($_POST);
$mail->IsSMTP(); // set mailer to use SMTP
// $mail->From = $_POST['email'];
$mail->FromName = $_POST['voornaam']." ".$_POST['achternaam'];
$mail->Host = "mail.chello.nl"; // this is my smtp server from my provider
$mail->AddAddress("mail@to.com");
// $mail->AddReplyTo("reply@mail.com", "Reply");
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = $_POST['onderwerp'];
$mail->Body = "
<div id='mail'>
<table>
<tr>
<td colspan='2'><h2>".$_POST['onderwerp']."</h2></td>
</tr>
<tr>
<td>Naam</td>
<td>".$_POST['voornaam']." ".$_POST['achternaam']."</td>
</tr>
<tr>
<td>Adres</td>
<td>".$_POST['adres']."</td>
</tr>
<tr>
<td>Postcode + Woonplaats</td>
<td>".$_POST['postcode']." ".$_POST['woonplaats']."</td>
</tr>
<tr>
<td>Telefoon</td>
<td>".$_POST['telefoon']."</td>
</tr>
<tr>
<td>E-mail</td>
<td>".$_POST['email']."</td>
</tr>
<tr>
<td>Onderwerp</td>
<td>".$_POST['onderwerp']."</td>
</tr>
<tr>
<td colspan='2'>Bericht</td>
</tr>
<tr>
<td colspan='2'>".$_POST['bericht']."</td>
</tr>
</div>
";
if ($mail->Send()) {
echo "Verzonden";
} else {
echo "wrong";
}
}
?>
<div id="contact_form">
<form action="#" method="post">
<input type="hidden" value="contact" name="post_form">
<table>
<tr>
<td>Naam</td>
<td><input type="text" name="voornaam" class="contact_inputfield"></td>
<td><input type="text" name="achternaam" class="contact_inputfield"></td>
</tr>
<tr>
<td>Adres</td>
<td colspan="2"><input type="text" name="adres" class="contact_inputfield_double"></td>
</tr>
<tr>
<td>Postcode + Woonplaats</td>
<td><input type="text" name="postcode" class="contact_inputfield"></td>
<td><input type="text" name="woonplaats" class="contact_inputfield"></td>
</tr>
<tr>
<td>Telefoon</td>
<td colspan="2"><input type="text" name="telefoon" class="contact_inputfield_double"></td>
</tr>
<tr>
<td>E-mail</td>
<td colspan="2"><input type="text" name="email" class="contact_inputfield_double"></td>
</tr>
<tr>
<td>Onderwerp</td>
<td colspan="2"><input type="text" name="onderwerp" class="contact_inputfield_double"></td>
</tr>
<tr>
<td valign="top">Bericht</td>
<td colspan="2"><textarea name="bericht" class="contact_textarea"></textarea> </td>
</tr>
<tr>
<td colspan="3"><input type="submit" value="Verzenden" class="contact_send"></td>
</tr>
</table>
</form>
</div>
It's good you're checking if the $mail->send()
works or not, but you're throwing away the error messages when it fails, which isn't good:
if ($mail->Send()) {
echo "Verzonden";
} else {
echo "failed: " . $mail->ErrorInfo;
}
However, you don't say how it's not sending the mail. PHP Mailer only hands off the mail to whatever mail server it's configured to use. The mail can still fail later on for other reasons, so if the $mail->send()
succeeds, then you'll have to check the mail server's logs.
Your server may have been blacklisted, or otherwise flagged as a spam source.
精彩评论