Django how to send_mail via local sendmail

Unfortunately, I can’t recreate your symptoms.

I installed sendmail in a server. I added the following lines to the settings.py file of a test project:

EMAIL_BACKEND='django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'localhost'
EMAIL_PORT = 25
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_USE_TLS = False
DEFAULT_FROM_EMAIL = 'default_from_email@email.com'

I then ran the following lines from a shell_plus session:

from django.core.mail import send_mail
send_mail('Subject', 'This is a message', 'ken@localhost', ['root@localhost'],fail_silently=False,)

And it all worked. No errors were thrown by the code and the emails were put in the /var/spool/mqueue directory.

All this was done on an Ubuntu 20.04 system, which I know has some (significant) differences regarding network controls and many other security/stability items that are in BSD and not in Linux.

I guess all I can say here then is that I think the issues are environmental and not necessarily Django related.

Does FreeBSD support the sendmail command-line client where you can try to do the following?

$ sendmail -v someone@email.com
From: you@yourdomain.com
Subject: This is the subject field of the email
This is the message to be sent.
.

Note: For all lines after the sendmail command, there will be no prompt. The line consisting of only a period - . followed by a new line marks the end of the entered data, and then you’ll see sendmail sending the email.