我正在使用AJAX和PHP发送电子邮件与数据从联系形式。我使用以下PHP:
if (mail($recipient, $subject, $email_content, $email_headers)) {
// Set a 200 (okay) response code.
http_response_code(200);
} else {
// Set a 500 (internal server error) response code.
http_response_code(500);
echo "Oops! Something went wrong and we couldn't send your message.";
}这是很好的工作,但如果这第一封电子邮件是发送,我也想发送一个新的参数确认电子邮件。我想我可以在200个响应代码之后设置另一个mail()函数,如:
if (mail($recipient, $subject, $email_content, $email_headers)) {
// Set a 200 (okay) response code.
http_response_code(200);
mail($email, $confirmation_subject, $confirmation_content, $confirmation_headers);
} else {
// Set a 500 (internal server error) response code.
http_response_code(500);
echo "Oops! Something went wrong and we couldn't send your message.";
}但这并没有导致电子邮件被发送。如果发送管理电子邮件,实现确认电子邮件的正确方法是什么。
发布于 2016-09-17 17:50:31
当您将头文件发回时,执行基本停止。我从未见过它的记录,但我以前也被它咬过。试着改变这两个顺序:
http_response_code(200);
mail($email, $confirmation_subject, $confirmation_content, $confirmation_headers);至
mail($email, $confirmation_subject, $confirmation_content, $confirmation_headers);
http_response_code(200);https://stackoverflow.com/questions/39548738
复制相似问题