mirror of
https://github.com/FAUSheppy/atlantis-event-dispatcher
synced 2025-12-06 06:21:36 +01:00
fix: make smtp port configurable
This commit is contained in:
@@ -24,7 +24,8 @@ def debug_send(uuid, data, fail_it=False):
|
|||||||
confirm_dispatch(uuid)
|
confirm_dispatch(uuid)
|
||||||
|
|
||||||
|
|
||||||
def email_send(dispatch_uuid, email_address, message, smtp_target, smtp_user, smtp_pass):
|
def email_send(dispatch_uuid, email_address, message, smtp_target,
|
||||||
|
smtp_target_port, smtp_user, smtp_pass):
|
||||||
'''Send message via email'''
|
'''Send message via email'''
|
||||||
|
|
||||||
if not email_address:
|
if not email_address:
|
||||||
@@ -33,7 +34,7 @@ def email_send(dispatch_uuid, email_address, message, smtp_target, smtp_user, sm
|
|||||||
return
|
return
|
||||||
|
|
||||||
subject = "Atlantis Dispatch"
|
subject = "Atlantis Dispatch"
|
||||||
smtphelper.smtp_send(smtp_target, smtp_user, smtp_pass, email_address,
|
smtphelper.smtp_send(smtp_target, smtp_target_port, smtp_user, smtp_pass, email_address,
|
||||||
subject, message)
|
subject, message)
|
||||||
confirm_dispatch(dispatch_uuid)
|
confirm_dispatch(dispatch_uuid)
|
||||||
|
|
||||||
@@ -127,6 +128,7 @@ if __name__ == "__main__":
|
|||||||
parser.add_argument('--smtp-target')
|
parser.add_argument('--smtp-target')
|
||||||
parser.add_argument('--smtp-user')
|
parser.add_argument('--smtp-user')
|
||||||
parser.add_argument('--smtp-pass')
|
parser.add_argument('--smtp-pass')
|
||||||
|
parser.add_argument('--smtp-port', type=int)
|
||||||
|
|
||||||
parser.add_argument('--loop', default=True, action=argparse.BooleanOptionalAction)
|
parser.add_argument('--loop', default=True, action=argparse.BooleanOptionalAction)
|
||||||
|
|
||||||
@@ -151,6 +153,7 @@ if __name__ == "__main__":
|
|||||||
smtp_target = args.smtp_target or os.environ.get("SMTP_TARGET")
|
smtp_target = args.smtp_target or os.environ.get("SMTP_TARGET")
|
||||||
smtp_user = args.smtp_user or os.environ.get("SMTP_USER")
|
smtp_user = args.smtp_user or os.environ.get("SMTP_USER")
|
||||||
smtp_pass = args.smtp_pass or os.environ.get("SMTP_PASS")
|
smtp_pass = args.smtp_pass or os.environ.get("SMTP_PASS")
|
||||||
|
smtp_port = args.smtp_port or os.environ.get("SMTP_PORT")
|
||||||
|
|
||||||
first_run = True
|
first_run = True
|
||||||
while args.loop or first_run:
|
while args.loop or first_run:
|
||||||
@@ -192,7 +195,8 @@ if __name__ == "__main__":
|
|||||||
ntfy_send(dispatch_uuid, user_topic, title, message,
|
ntfy_send(dispatch_uuid, user_topic, title, message,
|
||||||
ntfy_push_target, ntfy_user, ntfy_pass)
|
ntfy_push_target, ntfy_user, ntfy_pass)
|
||||||
elif method == "email":
|
elif method == "email":
|
||||||
email_send(dispatch_uuid, email_address, message, smtp_target, smtp_user, smtp_pass)
|
email_send(dispatch_uuid, email_address, message, smtp_target,
|
||||||
|
smtp_port, smtp_user, smtp_pass)
|
||||||
elif method == "debug":
|
elif method == "debug":
|
||||||
debug_send(dispatch_uuid, entry)
|
debug_send(dispatch_uuid, entry)
|
||||||
elif method == "debug-fail":
|
elif method == "debug-fail":
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import smtplib
|
|||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from email.mime.multipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
|
|
||||||
def smtp_send(server, user, password, recipient, subject, body):
|
def smtp_send(server, port, user, password, recipient, subject, body):
|
||||||
|
|
||||||
# Email and password for authentication
|
# Email and password for authentication
|
||||||
sender_email = f'{user}@{server}'
|
sender_email = f'{user}@{server}'
|
||||||
@@ -13,7 +13,7 @@ def smtp_send(server, user, password, recipient, subject, body):
|
|||||||
|
|
||||||
# SMTP server details
|
# SMTP server details
|
||||||
smtp_server = server
|
smtp_server = server
|
||||||
smtp_port = 25 # Default port for TLS connection
|
smtp_port = port or 25
|
||||||
|
|
||||||
# Create a message
|
# Create a message
|
||||||
message = MIMEMultipart()
|
message = MIMEMultipart()
|
||||||
|
|||||||
Reference in New Issue
Block a user