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
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…
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)}")
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.
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…
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.