Side note: When needing to preformat multiple lines, enclose the code between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. (I’ve taken the liberty of fixing your original post for you.)
EMAIL_HOST needs to be the dns name or ip address of the email server, not a port number.
And now this other error comes back. What can I do to make sure it is just a timeout problem and not something else ?
Below is the error
Error sending email: <class 'TimeoutError'> [WinError 10060] Unable to establish connection. Incorrect response from the connected party after the time interval or no response from the connected host.
[16/Mar/2024 17:28:03] "POST /email/ HTTP/1.1" 200 54
This time I hope I did not make a mistake with the backticks.
Thanks for the suggestions but nothing to do.
I specify that I am doing the tests on a local production pc. I don’t know if thiso can affect it. Yes from this pc I send e-mails attrvaerso the roundcube webMail
I also specify that I use the file.env to set the parameters even if it is of little use, since they are definitie in the settings.py file
I modified the view code making it simple
if request.method == 'POST':
send_mail('Subject to Send MAIL', 'Message to send mail', 'info@yourpersonalesoftware.it', ['gaetano.leoni@gmail.com'])
...
But the result doesn’t change
For completeness I repost the whole code
view
from django.core.mail import send_mail
from django.conf import settings
def send_email(request):
try:
if request.method == 'POST':
send_mail('Subject to Send MAIL', 'Message to send mail', 'info@yourpersonalesoftware.it', ['gaetano.leoni@gmail.com'])
except Exception as e:
print("Error sending email:", type(e), e)
return HttpResponse('An error occurred while sending the email.')
.env
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST=yourpersonalsoftware.it
EMAIL_PORT = 465 # Porta SMTP
EMAIL_USE_SSL = True # Abilita SSL/TLS
#Dettagli di autenticazione
EMAIL_HOST_USER='info@yourpersonalsoftware.it'
EMAIL_HOST_PASSWORD = 'XXXX' # La tua password email
#Impostazioni aggiuntive se necessarie
#DEFAULT_FROM_EMAIL = 'donotreply@example.com' # Indirizzo email predefinito del mittente
Sicuramente sarà un errore stupido ma non lo riesco a capire.
.env
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST=yourpersonalsoftware.it
EMAIL_PORT = 465 # Porta SMTP
EMAIL_USE_SSL = True # Abilita SSL/TLS
#Dettagli di autenticazione
EMAIL_HOST_USER='info@yourpersonalsoftware.it'
EMAIL_HOST_PASSWORD = 'XXXX' # La tua password email
#Impostazioni aggiuntive se necessarie
#DEFAULT_FROM_EMAIL = 'donotreply@example.com' # Indirizzo email predefinito del mittente
.env
# eMail
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = config('EMAIL_HOST')
EMAIL_PORT = config('EMAIL_PORT')
#EMAIL_HOST_TLS = config('EMAIL_USE_TLS')
EMAIL_HOST_SSL = config('EMAIL_USE_SSL')
Surely it will be a stupid mistake but I can't understand it.
I’m not asking if you send emails from this system.
Do you have an email server installed on yourpersonalsoftware.it ? (Roundcube is an email client, not an email server. Since it is an email client, you can check to see what its configuration is to see what email server it connects to.)
If you do not have an email server installed, then this cannot be your EMAIL_HOST.
What you are looking for is your email server that allows you to make an SMTP connection.