繁体   English   中英

PHP邮件重定向问题

[英]PHP mailer redirect issue

我遇到了一个使用PHPmailer的问题,我只是不明白。 我有一个辅助功能重定向头功能,在所示位置100%工作。 它无法在我希望它工作的评论中显示的位置工作。 无论重定向功能放在何处,其他所有功能都能完美运行。 有任何想法吗? 这也是我的第一篇文章,如果已经有一个我找不到的解决方案,请提前道歉。

<?php

if(isset($_POST['replyall'])) {

    redirect("index.php?leadreply");   // Why does this have to be here to work???? //       

    if(isset($_POST['chk1'])) { 

        $email = new PHPMailer();
        $email->From      = $_POST['author'];
        $email->FromName  = 'JGM Decorating';
        $email->Subject   = 'Reply to your contact request';
        $email->Body      = $_POST['comments'];
        $email->AddAddress( $_POST['destination'] );

        $file_to_attach = '../crm/gtcjgm.pdf';

        $email->AddAttachment( $file_to_attach , 'Terms and Conditions.pdf' );

        return $email->Send();

        // I would like to have the redirect here but it doesn't work??//

     } else {

        $email = new PHPMailer();
        $email->From      = $_POST['author'];
        $email->FromName  = 'JGM Decorating';
        $email->Subject   = 'Reply to your contact request';
        $email->Body      = $_POST['comments'];
        $email->AddAddress( $_POST['destination'] );

        $file_to_attach = '';

        $email->AddAttachment( $file_to_attach , 'Terms and Conditions.pdf' );    

        return $email->Send(); 

        // I would like to have a different redirect here but it doesn't work??//      

    }
}
?>

这段代码:

return $email->Send();

说明:这将返回该函数,它将在此阶段停止进程,然后在您放置的任何行之后它将无效。 (例如)Echo语句也不起作用。

如果你想同时做两件事,你必须使用Ajax进行邮件发送过程,之后你必须根据需要重定向。

由于返回将在该时刻自行停止执行。 所以为了做到这一点,你可以使用它与AJAX,然后重定向它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM