我今天被联系到从一个域发送大量垃圾邮件。这是一个相对简单的 php 网站,带有一个包含姓名、电子邮件、电话和消息的联系表。除非整个服务器被黑客入侵,否则我看不到该网站可用于向多个用户发送垃圾邮件的任何其他方式。
电子邮件经过验证,错误字符从邮件正文中删除。我尝试了多种方法来尝试通过表单修改标题,但似乎无法正常工作,所以我开始认为表单是安全的。
这是表单验证:
$to='owner@website.com';
$messageSubject='Enquiry from the website';
$confirmationSubject='Your email to website.com';
$confirmationBody="Thankyou for your recent email enquiry to website.com.\n\nYour email has been sent and we will get back to you as soon as possible.\n\nThe message you sent was:\n";
$email='';
$body='';
$displayForm=true;
if ($_POST){
$email=stripslashes($_POST['email']);
$body=stripslashes($_POST['body']);
$name=stripslashes($_POST['name']);
$phone=stripslashes($_POST['phone']);
// validate e-mail address
$valid=eregi('^([0-9a-z]+[-._+&])*[0-9a-z]+@([-0-9a-z]+[.])+[a-z]{2,6}$',$email);
$crack=eregi("(\r|\n)(to:|from:|cc:|bcc:)",$body);
$spam=eregi("http",$body);
$businessBody = "Enquiry from: $name\nEmail: $email\nPhone: $phone\n\nMessage:\n$body";
if ($email && $body && $phone && $name && $valid && !$crack & !$spam){
if (mail($to,$messageSubject,$businessBody,'From: '.$email."\r\n") && mail($email,$confirmationSubject,$confirmationBody.$body,'From: '.$to."\r\n")){
$displayForm=false;
echo "<div><p>Your message to us was sent successfully, and a confirmation copy has also been sent to your e-mail address.</p><p>Your message was:<br>".htmlspecialchars($body)."</p></div>";
}
else echo '<div class="emailMessage"><p>Something went wrong when the server tried to send your message. This might be due to a server error, and is probably not your fault. We apologise for any inconvenience caused. You are welcome to telephone us on 01383 625110</p></div>'; // the messages could not be sent
}
else if ($crack) echo '<div class="emailMessage"><p>Your message contained e-mail headers within the message body. This seems to be a cracking attempt and the message has not been sent.</p></div>'; // cracking attempt
else if ($spam) echo '<div class="emailMessage"><p>Your message contained characters that our system has flagged as spam email and has not been sent.</p></div>'; // spam mail!
else echo '<div class="emailMessage"><p>Your message could not be sent. You must complete all fields - name, phone number, e-mail address and a message.</p></div>'; // form not complete
}
任何人都可以看到这种形式可以被滥用的方式吗?
编辑
事实证明,有人在为群发邮件构建的服务器上放置了另一个加密文件,所以它实际上并不是来自这种形式。无论如何感谢您的答案,他们可能会帮助其他人!