1

我为用户注册制作了一个表格,当他们单击提交按钮时,一封活动电子邮件将发送到他们的电子邮件并转到索引页面。这是代码

/*
code config for PHPMailer
*/
$mail->Send();
header("location: index.php");

问题是要花一些时间等待 $mail->Send(); 或 mail($user_email,$subject,$content) 完成。当用户单击提交按钮时,如何会转到 index.php 并在后台发送电子邮件。感谢!

4

3 回答 3

0

PHP is single-thread which means it will just work it's way though the script. It will wait when doing something and continue when it's finished.

What you want is not possible.

You COULD however try an approach with Ajax and two separate scripts.

于 2013-07-01T10:17:42.043 回答
0

您可以向邮件功能添加其他参数

$additional_parameters = "O DeliveryMode=b";
mail ($to, $subject,$message, $additional_headers, $additional_parameters)

希望它会工作

于 2013-07-01T10:26:46.850 回答
-1

May be try something like this:

<?php if( $mail->Send(); ) { header("location: index.php"); }
于 2013-07-01T10:16:13.590 回答