Error 500 email attaching files > 15 Mb AjaxUploadAttachments

I have a long form, should be possible to upload 5 files of 5Mb each one; when I upload more than 3 files (> 15mb) I get the 500 error, I can see all the files are uploaded, but are not sent in the email as attached, not even an email message is being sent, contrary if I upload mutliple files with less of equal of 15Mb in total.

  • The SMTP is configured to send 30 Mb, so that shouldn’t be the problem.
  • When I remove AjaxUploadAttachments hook from the form it, of course I don’t see the error, and I don’t have the email message in my inbox.
  • I don’t have any clue on the logs.

Modx 2.8.5

I appreciate your help.

It can be a timeout of PHP with the large size of the attachments. They have to be encoded for the mail and sending them consumes also time. Do smaller files work?

If yes, you could try to increase the timeout.

You should also check the PHP error log for a different cause of the error. Timeouts are normally not logged if I remember right.

Hi Jako, thanks for your answer and your wonderful extras.

It works perfectly with smaller files, the error happens only when the summary of the files is higher than 15 MB.

I’m using Modx Cloud, and I have these values configured:

memory_limit: 128M
max_execution_time: 30
upload_max_filesize: 50M
post_max_size: 50M

So I will need to increase the max_execution_time and test it, I will try to do this via SSH.


Many thanks for the flowers :smiley:

There is a debug setting in phpMailer. You can add that in the code of the email hook. This could help to understand what is going wrong during preparing and sending the mail.

If you can’t change the timeout: I have built a mailqueue implementation for one of my commercial extras which can go into a different extra.

Or you can save the files on the server and just send links to the files.

Hope that helps

Finally, the client agreed to have the files as links in the email message.
Here is the snippet that is called from the email template, if it could be useful to someone.

$files = explode(',', $files);
$baseUrl = $modx->getOption('site_url');
$fullUrls = [];
foreach ($files as $file) {
    $fullUrls[] = $baseUrl . ltrim($file, '/');
return implode("<br>", $fullUrls);

Thanks again @jako

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.