Search code examples
phphttp-redirectmailto

How to redirect a page after a mailto redirect in pure PHP 7.1


So I'm building a web application in PHP 7.1, no frameworks whatsoever and after filling in a form i'm redirecting to a mailto link like so:

header("Location: mailto:$mail?subject=$subje&body=$mailstring&message=" . $succes, true);

It's a constructed string, but I know it works since it results in the email that I want. But after that I want te page to continue to another page, like usual after a form submit. Is that possible and if so, how? The &message part is for the page that I want to go to after the form submits and opens the mail. If I need to use a small javascript for this(without jquery or anything) it'd be fine as well.

Thanks in advance.


Solution

  • I figured out that this isn't really possible in PHP so I did it using Javascript' window.open() for the mailto. Immediately closing the empty pane that opens and then redirecting the page, like so:

            let mail = "mailto:" + findGetParameter("mail") + "?subject=" + findGetParameter("subject") + "&body=" + findGetParameter("body");
            let newmail = encodeURI(mail);
            win = window.open(newmail);
            while(!win.closed) {
                win.close();
            }
            window.location.href = uri + "/Action/Page.php?message=" + findGetParameter("message");