send eMail from form

Hi, I made a web page to allow the user to send a message via eletrronic mail.
I post the setting of the settings.py file.

# eMail
DEFAULT_FROM_EMAIL= 'info@personalsoftware.it'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST_USER = config('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD')
# EMAIL_HOST_TLS = config('EMAIL_HOST_TLS')
EMAIL_PORT = config('EMAIL_PORT')
EMAIL_HOST = config('EMAIL_HOST')

And the setting of the .env file

EMAIL_HOST_USER=info@personalsoftware.it
EMAIL_HOST_PASSWORD=XXXXX
EMAIL_USE_TLS=True
EMAIL_PORT=587
EMAIL_HOST=993

But it returns this error

Error sending email: <class 'socket.gaierror'> [Error 11001] getaddrinfo failed
[16/Mar/2024 11:52:36] "POST /email/ HTTP/1.1" 200 54

I placed prints in the view file and the error occurs when I launch the send_mail() function

I don’t know if the settings are correct and I don’t understand where I am wrong
Thanks

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.

I apologize again and thank you for editing it.
I have made lal modification as you suggested

EMAIL_HOST_USER=info@yourpersonalsoftware.it
EMAIL_HOST_PASSWORD=XXX
EMAIL_USE_TLS=True
EMAIL_PORT=587
EMAIL_HOST=www.yourpersonalsoftware.it

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.

I removed the www. but same result

I’ll post the viewa code. I saw that EmailMessage is used and not send_mail
I don’t know if it is the same thing

def send_email(request):
    try:
        if request.method == 'POST':
            name = request.POST.get('name', '')
            email = request.POST.get('email', '')
            object = request.POST.get('object', '')
            message = request.POST.get('message', '')

            # Send the email
            send_mail(
                subject = subject,
                message = f "From: {name}\nEmail: {email}\nMessage: {message}"
                from_email = email,
                recipient_list = ['info@yourpersonalesoftware.it'],
                fail_silently = False,
            )
            print("Email sent successfully")
            return HttpResponse('workwithus.html')

    except Exception as e:
        print("Error sending email:", type(e), e)
        return HttpResponse('An error occurred while sending the email.')

Are you running an email server on this system? If not, then this setting is supposed to be the SMTP server that is responsible for sending emails.

use this setting, i did it like this: check email host, and use SSL instead of TLS, and enable ssl/tsl both: I hope it will work for you.

EMAIL_BACKEND = ‘django.core.mail.backends.smtp.EmailBackend’
EMAIL_HOST = ‘mail.example.com’ # Outgoing Server
EMAIL_PORT = 465 # SMTP Port
EMAIL_USE_SSL = True # Enable SSL/TLS

#Authentication details
EMAIL_HOST_USER = ‘donotreply@example.com’ # Your email address
EMAIL_HOST_PASSWORD = ’ ’ # Your email password

#Additional settings if needed
DEFAULT_FROM_EMAIL = ‘donotreply@example.com’ # Default sender email address

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

.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')
#DEFAULT_FROM_EMAIL= 'info@yourpersonalsoftware.it'
EMAIL_HOST_USER = config('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD')

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.