Attach PDF issue

Hi David, for those of us who have no idea whether we are using phantomJS or not and don’t even know what that means, but are still having this issue with the emails not sending when attach PDF is checked, could you tell us what we should change to PDF_GENERATOR=hosted_ninja and where we would find that? It happens when I set up a Zap in Zapier. Is it something I’d change in the Zap?

Thanks :slight_smile:

@david my ENV file shows PDF_GEN is already set to hosted_ninja

@RedTape go to your root folder of invoiceninja . should /var/www/html/ninja or something similar

then type

nano .env

What are you hosting your instance of Invoice Ninja on? Are you using cPanel?
If so in your public_html directory you will find a .env file. In this file you will find which PDF generator you are using (line 49).

If you are using Linux then proceed with Randy’s guide.

If you are using the hosted version of Invoice Ninja, then contact their support team directly.

1 Like

Do you have a white label license? The hosted_ninja PDF generator will not function without it.

yes purchased the white label lic. , use local on prem. debian 11


This is puzzling, I’ve tested locally and cannot recreate this. Can you advise your mailing configuration please?

One thing to try for those that are suffering with this issue, in the .env file please change


then reoptimize your cache (php artisan optimize) or delete the contents of bootstrap/cache/

Then reattempt to send an email.

If you then open the log file in storage/logs/laravel.log

The contents of the email - included the PDF - will be dumped to this file, if you are seeing the PDF inside this file it means the system is correctly attaching the PDFs to the emails - so there may be something within the mail server that is removing the attachments?

Once we have this information we’ll be able to move forward with debugging.


so i did the change but i dont see any confirming info

[2022-01-19 15:00:07] production.ERROR: Unable to create lockable file: /var/www/html/ninja/storage/framework/cache/data/db/d3/dbd349546ec3e87e258c52bb7fdd97a0c336dcdb. Please ensure you have permission to create files in this >

i checked our permissions

/var/www/html/ninja/storage/framework# ls -l
total 16
drwxrwxrwx 3 www-data www-data 4096 Dec 29 13:41 cache
drwxrwxrwx 2 www-data www-data 4096 Jan 19 12:35 sessions
drwxrwxrwx 2 www-data www-data 4096 Dec 27 15:00 testing
drwxrwxrwx 2 www-data www-data 4096 Jan 19 12:35 views

You should check permissions recursively down the directory tree. Try

find /var/www/html/ninja/ \( ! -user www-data -o ! -perm -644 \) -ls
(You might need to escape the “!” as well, depending on the shell you use.)

Probably irrelevant for this issue, but if you haven’t done some special tweaking to the MTA’s config it’s usually either






so what should i see when i run the find command

i orignally had several folders /ninja/storage /ninja/public/storage and server files in /var/www/html/ninja/bootstrap/cache that were showing root root

i adjusted all the folders to www-data that seems to of fixed using MAIL_MAILER=“log”

it will now process the email via the log . but when i change to hosted_ninja it still fails . i am not seeing any logs .

i can send a email to with not issues unless i add the PDF

doing more troubleshooting it looks like it isnt a PDF issue . it only fails when i have both PDF and Documents attached .

if i select PDF only then it seems to send
if i select PDF and Documents it will fail.

any clue ?

@david any thoughts?


Ok this is progress.

From within the application, when you navigate to the documents tab, do the documents open / download / view normally?

It may be that the system is not able to pull the URLs of the documents which may indicate that you APP_URL is not set correctly.

so yes i can open PDF/Word docs or PICs that are uploaded to the portal.

the only thing that it could be if its related to the URL is we are behind a PFsense HA proxy server

ok so after reading
[ ] thread , i went in an looked at my NGINX Conf file .

running latest version of PFSense and HA Proxy on the frontend , i removed these lines from the Ninja NGINX Conf file

#Removed the fallowing lines from the origanal Ninja Nginx Conf file
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers ‘AES128+EECDH:AES128+EDH:!aNULL’;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

this then fixed the issue with documents not sending . SSL still works as expected

Thanks for sharing this!

cc @david