Search code examples
djangosmtpionos

Django STMP with IONOS


Having an adress mail managed by IONOS, I'm struggling to set it up with Django to be able to send mails automatically.

Here's my error:

TimeoutError: [Errno 110] Connection timed out

I personnalized the SMTP in my settings:

DEFAULT_FROM_EMAIL="mymail"
EMAIL_HOST = 'smtp.ionos.fr'
EMAIL_HOST_USER = 'myusername' 
EMAIL_HOST_PASSWORD = 'mymdp'
EMAIL_PORT = 25
EMAIL_USE_SSL = True

and here's how I send mails:

from django.core.mail import send_mail
def send_forgotten_password_mail(self, request, pk=None):
    send_mail(
        'Subject here',
        'Here is the message.',
        None,
        ['tosend'],
        fail_silently=False,
    )

I'm not that used to send mails through SMTP with Django, so I might miss something.

Thank you for your help.


Solution

  • this works for me in settings.py:

    EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
    EMAIL_HOST = 'smtp.ionos.de'
    EMAIL_PORT = 587
    EMAIL_USE_TLS = True
    EMAIL_HOST_USER = 'myusername' 
    EMAIL_HOST_PASSWORD = 'mypw'
    

    Remark: of course PASSWORD should be read from an environment variable and not placed in setttings.py, but that is not the topic of the question here.