[Solved]-Django mails not being saved (File backend)

3👍

As you can see in the code there’s a lot of raises:
https://github.com/django/django/blob/stable/2.1.x/django/core/mail/backends/filebased.py#L13

So if with your settings, and the correct permissions on your folder you cannot see email or errors maybe there’s some settings that overwrite the two settings you posted here.

Check again your local setting and be sure there’s only one EMAIL_BACKEND declared.

3👍

I had this issue when trying to get auth working, specifically the password reset. It took me hours to discover that the e-mail address I was using for the reset did not exist for any users in my database, and of course it’s good security that Django remains silent about it. Dumb error but I wish someone had posted about it, so here it is.

2👍

Because there is no error, the directory exists and there are still no files created in your specified directory, it is possible that the code runs and creates the files but in a different directory.

What is your file_path keyword set to when you create a connection?

File backend

The file backend writes emails to a file. A new file is created for
each new session that is opened on this backend. The directory to
which the files are written is either taken from the EMAIL_FILE_PATH
setting or from the file_path keyword when creating a connection with
get_connection().

To specify this backend, put the following in your settings:

EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
EMAIL_FILE_PATH = '/tmp/app-messages' # change this to a proper location

Django Docs File Backend

👤Angela

0👍

It seems that EMAIL_FILE_PATH refers to the absolute path.
For me this solution works:

EMAIL_FILE_PATH = os.path.join(BASE_DIR, 'app/emailfolder')
👤Björn

-1👍

I spent some time on this myself and after some frustration, I just swapped the two variables, and it worked.

EMAIL_FILE_PATH = '/code/mails/'
EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'

Leave a comment