Commit 0f7898ad authored by David Trattnig's avatar David Trattnig
Browse files

Ability to disable sending of mails. #38

parent ccf246e0
......@@ -18,16 +18,19 @@ db_charset="utf8"
[monitoring]
mail_server="mail.example.com"
mail_server="mail.your-radio.org"
mail_server_port="587"
mail_user="aura@subsquare.at"
mail_pass="---SECRET--PASSWORD---"
# If you want to send multiple adminmails, make them space separated
admin_mail="david@subsquare.at"
# Which from mailadress should be used
# Set to "true" if you want to notify admins about incidents, otherwise "false"
mail_admin_enabled="true"
# If you want to send multiple admin-mails, make them space separated
admin_mail="admin@your-radio.org"
# The FROM email address used when sending
from_mail="monitoring@aura.engine"
# The beginning of the subject. With that you can easily apply filter rules using a mail client
mailsubject_prefix="[Aura Engine]"
# A subject prefix allows applying filter rules in your mail client
mailsubject_prefix="[AURA Engine]"
# Server where heartbeat info is sent to
heartbeat_server = "127.0.0.1"
# Some UDP port
......@@ -36,9 +39,10 @@ heartbeat_port = 43334
heartbeat_frequency = 1
logdir="/home/username/code/aura/engine/logs"
# possible values: debug, info, warning, error, critical
# Possible values: debug, info, warning, error, critical
loglevel="info"
[api]
## STEERING ##
......
......@@ -18,27 +18,31 @@ db_charset="utf8"
[monitoring]
mail_server="mail.example.com"
mail_server="mail.your-radio.org"
mail_server_port="587"
mail_user="aura@subsquare.at"
mail_pass="---SECRET--PASSWORD---"
# If you want to send multiple adminmails, make them space separated
admin_mail="david@subsquare.at"
# Which from mailadress should be used
# Set to "true" if you want to notify admins about incidents, otherwise "false"
mail_admin_enabled="true"
# If you want to send multiple admin-mails, make them space separated
admin_mail="admin@your-radio.org"
# The FROM email address used when sending
from_mail="monitoring@aura.engine"
# The beginning of the subject. With that you can easily apply filter rules using a mail client
mailsubject_prefix="[Aura Engine]"
# A subject prefix allows applying filter rules in your mail client
mailsubject_prefix="[AURA Engine]"
# Server where heartbeat info is sent to
heartbeat_server = "127.0.0.1"
heartbeat_server = "127.0.0.1"
# Some UDP port
heartbeat_port = 43334
# Seconds how often the vitality of the Engine should be checked (0 = disabled)
heartbeat_frequency = 1
logdir="/srv/logs"
logdir="/home/username/code/aura/engine/logs"
# Possible values: debug, info, warning, error, critical
loglevel="info"
[api]
## STEERING ##
......
......@@ -18,27 +18,31 @@ db_charset="utf8"
[monitoring]
mail_server="mail.example.com"
mail_server="mail.your-radio.org"
mail_server_port="587"
mail_user="aura@subsquare.at"
mail_pass="---SECRET--PASSWORD---"
# If you want to send multiple adminmails, make them space separated
admin_mail="david@subsquare.at"
# Which from mailadress should be used
# Set to "true" if you want to notify admins about incidents, otherwise "false"
mail_admin_enabled="true"
# If you want to send multiple admin-mails, make them space separated
admin_mail="admin@your-radio.org"
# The FROM email address used when sending
from_mail="monitoring@aura.engine"
# The beginning of the subject. With that you can easily apply filter rules using a mail client
mailsubject_prefix="[Aura Engine]"
# A subject prefix allows applying filter rules in your mail client
mailsubject_prefix="[AURA Engine]"
# Server where heartbeat info is sent to
heartbeat_server = "127.0.0.1"
heartbeat_server = "127.0.0.1"
# Some UDP port
heartbeat_port = 43334
# Seconds how often the vitality of the Engine should be checked (0 = disabled)
heartbeat_frequency = 1
logdir="/var/log/aura"
# *ossible values: debug, info, warning, error, critical
logdir="/home/username/code/aura/engine/logs"
# Possible values: debug, info, warning, error, critical
loglevel="info"
[api]
## STEERING ##
......
......@@ -17,11 +17,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
import smtplib
from email.message import EmailMessage
from src.base.config import AuraConfig
from src.base.utils import SimpleUtil as SU
class MailingException(Exception):
......@@ -35,8 +38,6 @@ class MailingException(Exception):
class AuraMailer():
"""
Event handler to send emails to Aura administrators and programme coordinators.
"""
engine = None
mail = None
......@@ -92,7 +93,9 @@ class MailService():
Service to send emails to Aura administrators.
"""
config = None
logger = None
admin_mails = None
admin_mails_enabled = None
def __init__(self):
......@@ -100,7 +103,9 @@ class MailService():
Constructor
"""
self.config = AuraConfig.config()
self.logger = logging.getLogger("AuraEngine")
self.admin_mails = self.config.get("admin_mail")
self.admin_mails_enabled = self.config.get("mail_admin_enabled")
#
......@@ -116,6 +121,10 @@ class MailService():
subject (String): The email subject
body (String): The email body text
"""
if self.admin_mails_enabled == "false":
self.logger.warning(SU.red("No admin mail sent, because doing so is disabled in engine.ini!"))
return False
admin_mails = self.admin_mails.split()
for mail_to in admin_mails:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment