Configuring SMTP in Docker
In order to enable email alerts and reports, you need to configure your SMTP server details on the DNIF containers.
The configuration can be done manually by editing a YAML template file that comes with the Datastore, Correlator, and A10 installations.
The Datastore, Correlator, and A10 containers will connect to your email server on the SMTP port from their network address. For example, if your email server is configured for SMTP ports 25, 465, 587, or any other, make sure that these ports are reachable from the DNIF Container.
Steps to configure SMTP in DNIF Container
Step-2: Move to the ‘/dnif/<Deployment-key/tool’ folder path.
Step-3: Here, you will find smtp.yaml template file and configsmtp.py python script.
root >cd /dnif/CfXXXXXXXXXXXXe3/tool/ root >ls configsmtp.py smtp.yaml
Step-4: Open the smtp.yaml template file and edit the required fields, while commenting/uncommenting as needed, with the correct values.
# Example config for internal smtp (without authentication) - internal: domain: 192.168.10.32 - from: [email protected] - target_email: [email protected] # Example config for external smtp (with authentication) # - external: # domain: 192.168.10.32 # username: myusername # password: mypassword # port: 465 # tls: 1 # - from: [email protected] # - target_email: [email protected]
This YAML template is divided in two sections:
- Without Authentication [Internal SMTP]
- With Authentication [External SMTP]
You will comment on the required section, as per your SMTP server requirements, and uncomment on the not required ones.
Note - YAML file is sensitive to white spaces and indentation. Hence, it is strongly recommended to make a copy of the template file before editing it.
Fields from the YAML template are explained below:
|domain||domain field contains the IP address or domain-name for your SMTP server||domain: [email protected] or domain: 126.112.xx.yy|
|port||SMTP port on your email-server [e.g. 25, 465, 587, etc.]||port: 465|
|from||DNIF alerts and reports shall be sent via the email address mentioned in the from field||from: [email protected]|
|target_email||During SMTP configuration configsmtp.py script will send a test email to the email address mentioned in the target_email field||target_email: [email protected]|
|username||Authorized SMTP username for sending emails||username: smtp_user|
|password||SMTP authentication password for the username above||password: smtp_password|
|tls||If your SMTP server is using a secure TLS, then set tls to 1, else to 0||tls: 1 or tls: 0|
An example for the smtp.yaml:
# Example config for internal smtp (without authentication) #- internal: # domain: 192.168.10.32 #- from: [email protected] #- target_email: [email protected] # Example config for external smtp (with authentication) - external: domain: smtp.dnif.it username: [email protected] password: S4**************!J port: 587 tls : 1 - from: [email protected] - target_email: [email protected]
Step-5: Save changes and close the smtp.yaml file.
Step-6: Now, execute the configsmtp.py script to apply the smtp.yaml configurations on the DNIF containers.
root > python configsmtp.py Configuration of SMTP tested and applied successfully
If the configuration is done correctly, you’ll see a ‘success’ message after running configsmtp.py
Besides, you will receive an email on target_email with the subject line Test Email with the sender’s name defined in the from field within smtp.yaml.