我想将在线电子邮件表格发送到两个地址。邮件的内容对于每个收件人都应该有所不同。一封邮件进行进一步处理(使用密码),另一封邮件作为个人副本(不使用密码)。
问题:
我创建的Web表单基本上可以运行,但是一些用户报告说他们没有得到个人副本。 我还不能重现该错误。 (请参阅下面的更新)我现在担心,有时它也不会将电子邮件发送到另一个地址。我认为这与邮件处理逻辑(process.php)有关...
如何避免这种奇怪的行为?我是否犯了编码错误?有什么要解决的吗?
非常感谢你的帮助!
这是示例代码:
<?php
$to = $_POST['email'];
$to2 = '[email protected]';
$from = $_POST['email'];
$subject = 'Webform for' . $_POST['firstname'] . ' ' . $_POST['lastname'];
$email = $_POST['email'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$password = $_POST['password'];
$comment = $_POST['comment'];
$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/plain; charset=utf-8";
$headers[] = "From: {$email}";
$headers[] = "X-Mailer: PHP/".phpversion();
$message1 = "
Hello $firstname $lastname, \n
here is your personal copy of the web form: \n
Name: $firstname $lastname
Comment: $comment \n
Bye, Admin";
$message2 = "
Name: $firstname $lastname
Password: $password
Comment: $comment";
$success = mail($to, $subject, $message1,implode("\r\n",$headers), '[email protected]'); // Personal copy
$success = mail($to2, $subject, $message2,implode("\r\n",$headers), '[email protected]'); // Further processing
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=form.php#success\">";
}
?>
更新[11-24-2015]:我只复制了一次该错误(很少发生)。丢失的电子邮件不会被过滤为垃圾邮件,也不会出现在其他任何地方。尚未找到解决方案。
您的代码看起来不错。
该电子邮件可能已被某些认为是垃圾邮件的提供商阻止。
正确发送电子邮件并非易事...
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句