我使用PHPMailer制作了一个联系人表单,该代码基于PHPMailer测试邮件,该邮件工作良好。
但是现在它就是不发送我的电子邮件,它一直显示我错了。Instead of Verzonden (sent)
这是我的代码
<?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>
检查$mail->send()
是否工作是好的,但是当它失败时,您会丢弃错误消息,这是不好的:
if ($mail->Send()) {
echo "Verzonden";
} else {
echo "failed: " . $mail->ErrorInfo;
}
然而,你没有说它是如何不发送邮件的。PHP Mailer只将邮件交给它配置使用的任何邮件服务器。由于其他原因,邮件稍后仍可能失败,因此如果$mail->send()
成功,则必须检查邮件服务器的日志。
您的服务器可能已被列入黑名单,或被标记为垃圾邮件源。