Smarty allows you to send emails via SMTP during certain events, such as: sending notifications to subscribers (for connecting packets, reminders about payments, etc.), alarm in case of accidents (triggers in the monitoring module).
To send a letter, you need to specify the data for connecting to the SMTP server in the Smarty configuration file:
DEFAULT_FROM_EMAIL— the address in the “From” field in the default service emails sent. Data type: string.SERVER_EMAIL— the same value as inDEFAULT_FROM_EMAIL.EMAIL_HOST— SMTP server address. Data type: string.EMAIL_PORT— SMTP server port. Data type: int.EMAIL_HOST_USER— user name. Data type: string.EMAIL_HOST_PASSWORD— password. Data type: string.EMAIL_USE_TLS— the flag depending on which TLS encryption protocol will be enabled or not. Data type: bool. By default True true.
Example of settings:
DEFAULT_FROM_EMAIL = 'robot@example.com'
SERVER_EMAIL = 'robot@example.com'
EMAIL_HOST = 'smtp.example.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'robot@example.com'
EMAIL_HOST_PASSWORD = 'z272LOCXmZdQ01yK'
EMAIL_USE_TLS = True
Efficiency check
To debug the sending of letters, you can use the following script. Start shell (root privileges required):
smarty_manage shell --settings=settings.smarty
Instead setting.smarty please specify your configuration file if it is different.
In the open shell, execute the script:
from django.core.mail import send_mail
send_mail("test", "message", None, ["mail@example.com])
The last team will send a letter to the specified address. If successful, code 1 will be returned.