Email from system not being sent

Hi All I am trying to get the email notifications to work. I am not sure where to find the logs to see why it is failing. I have an external mail server that I am using for some of my wordpress sites. I would like to tlook at the logs to see what is the problem

Thanks

I resolved the issue. This was restictions on my mail server

Could not send email “[Indico] Verify your email” (attempt 1/10); retry in 30s [Connection unexpectedly >
2024-01-16 17:56:26,644 WARNING 0000000000000000 - indico.emails Could not send email “[Indico] Verify your email” (attempt 2/10); retry in 60s [Connection unexpectedly >
2024-01-16 17:57:20,275 WARNING 0000000000000000 - indico.emails Could not send email “[Indico] Verify your email” (attempt 2/10); retry in 60s [Connection unexpectedly >
2024-01-16 17:57:56,714 WARNING 0000000000000000 - indico.emails Could not send email “[Indico] Verify your email” (attempt 3/10); retry in 120s [Connection unexpectedly>
2024-01-16 17:58:50,392 WARNING 0000000000000000 - indico.emails Could not send email “[Indico] Verify your email” (attempt 3/10); retry in 120s [Connection unexpectedly>
2024-01-16 17:59:38,355 INFO f061dbde3fa34e0d - indico.rh GET /contact [IP=37.99.87.206] [PID=1124]
2024-01-16 18:00:26,815 WARNING 0000000000000000 - indico.emails Could not send email “[Indico] Verify your email” (attempt 4/10); retry in 300s [Connection unexpectedly>
2024-01-16 18:01:20,474 WARNING 0000000000000000 - indico.emails Could not send email “[Indico] Verify your email” (attempt 4/10); retry in 300s [Connection unexpectedly>

whats the problrm?? i checked up smtp server it works by python. only server cant send…

what i did wrong or i didn’t?

Well, it cannot connect or the connection gets interrupted… we use the same code in Indico that Django uses for sending emails, so this is almost certainly a problem with your (filtered) internet connection (assuming the mail server is not local) or your mail server…

Now i use server internet vps hosting. And use yandex account. Problen in server i guess, have an idea?

We use write this code in python and it works:

import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

# Укажите свои учетные данные и параметры для SMTP-сервера
sender_email = ""
receiver_email = ""
password = ""
smtp_server = "smtp.yandex.kz"
smtp_port = 465

# Создаем объект MIMEMultipart
message = MIMEMultipart()
message["From"] = sender_email
message["To"] = receiver_email
message["Subject"] = "Валидация пользователя"

# Добавляем текст сообщения
body = "Привет, это текст вашего письма."
message.attach(MIMEText(body, "plain"))

try:
    # Устанавливаем соединение с SMTP-сервером
    with smtplib.SMTP_SSL(smtp_server, smtp_port) as server:
        # Входим в аккаунт
        server.login(sender_email, password)

        # Отправляем письмо
        server.sendmail(sender_email, receiver_email, message.as_string())

    print("Письмо успешно отправлено!")

except Exception as e:
    print(f"Произошла ошибка: {str(e)}")

It could connect by smtp in yandex mail server

Do they support STARTTLS (typically on port 587)? If yes try that and set SMTP_USE_TLS = True in your indico.conf.

It alredy wrote

I suspect it is the sender email (this not fixed in indico, it can be the mail configured on the event, the mail of the user triggering the mails, etc…). Yandex probably requires that login email and sender email be the same.

Thanks for the suggestion. However, our mail server only supports
implicit SSL (port 465), not STARTTLS (port 587).

Currently, Indico only supports SMTP_USE_TLS (STARTTLS), but not
implicit SSL connections. Would you consider adding SMTP_USE_SSL
parameter in future versions to support servers that only offer
SSL connections?

For now, we’re using socat as a workaround to tunnel the SSL
connection to localhost:25.

The django mail docs[1] mention 2 flags for the different SSL modes:

EMAIL_USE_SSL and EMAIL_USE_TLS

And that is also available int the indico email backend. But

indico/indico/web/flask/app.py at af5cf5c1b59885ef59f8eb540f12233ba405de0b · indico/indico · GitHub actually does hardcode USE_SSL to false.

See Add missing SMTP_USE_SSL option by bpedersen2 · Pull Request #7177 · indico/indico · GitHub for a fix.

[1] Sending email | Django documentation | Django

I just merged the PR, so once we release the next version (this will still happen this year) you can use it. Note that using the new option WILL break error log emails, because the logging module does not support SMTPS when sending emails…

I just found How can I send an email using python logging's SMTPHandler and SSL - Stack Overflow and will take a look if this can be integrated as well.

Yes, I found this as well. IMHO it will be very ugly because if you look at how emit is implemented in the original SMTPHandler you’d basically need to re-implement the whole method.