Where to store files for email attachments not to be available via URL ?

I have to send out newsletter PDFs using Django.
But this PDFs should not be served/available via URL.

Where should I store newsletter PDF files which will be attached to an email but at the same time files must NOT be served and accessible via URL ?

Thanks!

Pretty much anywhere you want that isn’t covered by a “static” or “media” url.

How are you sending out these PDFs? Is it something like a Celery task? Or on demand from a view?

Either way, it doesn’t matter. Keep in mind that your Django code running on the server has full access to all parts of the file system to which permission has been granted, not just those parts accessible via URL.

1 Like

So…what I did at the end is…in project settings.py I defined MY_FILES = os.path.join(BASE_DIR, 'myApp/MY_FILES/') and then in email sending function I used msg.attach_file(settings.MY_FILES +'file1.pdf')