updated mail config

This commit is contained in:
berkay 2025-04-25 14:49:20 +03:00
parent 0bd8ddce4d
commit b9825bb8e8
2 changed files with 7 additions and 6 deletions

View File

@ -36,7 +36,6 @@ def render_email_template(
)
except Exception as e:
print("Exception render template:", e)
err = e
raise
@ -66,8 +65,7 @@ def send_email_to_given_address(send_to: str, html_template: str) -> bool:
# Use the context manager to handle connection errors
with EmailService.new_session() as email_session:
# Send email through the service
EmailService.send_email(email_session, email_params)
return True
return EmailService.send_email(email_session, email_params)
except Exception as e:
print(f"Exception send email: {e}")
return False
@ -88,10 +86,10 @@ def set_account_records_to_send_email() -> bool:
account_records_query = AccountRecords.filter_all(db=db_session).query
# Get the 3 most recent records
account_records: List[AccountRecords] | [] = (
account_records: List[AccountRecords] = (
account_records_query.order_by(
AccountRecords.bank_date.desc(),
AccountRecords.bank_reference_code.desc(),
AccountRecords.iban.desc(),
)
.limit(3)
.all()
@ -99,6 +97,7 @@ def set_account_records_to_send_email() -> bool:
# Check if we have enough records
if len(account_records) < 2:
print(f"Not enough records found: {len(account_records)}")
return False
# Check for balance discrepancy
@ -109,6 +108,7 @@ def set_account_records_to_send_email() -> bool:
balance_error = expected_second_balance != second_record.bank_balance
if balance_error:
print(f"Balance error detected {expected_second_balance} != {second_record.bank_balance}")
return False
# Format rows for the email template
@ -151,5 +151,6 @@ def set_account_records_to_send_email() -> bool:
if __name__ == "__main__":
success = set_account_records_to_send_email()
print("Email sent successfully" if success else "Failed to send email")
exit_code = 0 if success else 1
exit(exit_code)

View File

@ -10,7 +10,7 @@ class Configs(BaseSettings):
USERNAME: str = ""
PASSWORD: str = ""
PORT: int = 0
SEND: bool = 0
SEND: bool = True
@property
def is_send(self):