goal
I am trying to create a PHP script that emails a rather large (6MB) PDF file to users on the website requesting it. The user enters their email address into the form, submits the form, and the file is sent to them through the PHP Mailer instance. When submitting the form, the user displays a success page.
Problem
After the data is transferred using the POST method, there is a long pause, and the server will eventually return 404. However, in a few minutes the email will be received perfectly with the PDF attachment.
Troubleshooting / Attempts
I attribute the PHP Mailer problem by simply taking too long to send an email due to a large attachment. The server shuts down and returns to return 404. At the same time, the script ultimately completes the processing and after that receives an email.
If I delete the attachment and just send an empty letter, the script will load very quickly and display a success / confirmation page.
I looked at creating a redirect, but wherever I found explanations on how to achieve a redirect in PHP, it says that you should kill the original script (which I don't want to do).
Question
How to allow an email script to spend its time launching while displaying a success message to the user so they donβt get confused?
source share