nowy mail i funkcja

This commit is contained in:
Mateusz Gruszczyński
2025-05-18 23:37:27 +02:00
parent 1b819dc403
commit bf144448b4

15
app.py
View File

@ -205,16 +205,17 @@ def send_email_batch(users, smtp_config, mails_per_pack=100, time_per_pack=60, d
continue
try:
last_login = user.get('access', 0) # Domyślnie 0 jeśli brak
reg_date = user.get('created', 0) # Domyślnie 0 jeśli brak
msg = MIMEMultipart()
from_email = smtp_config["user"] or "unitra@unitraklub.pl"
msg['From'] = f"Unitra-Klub <{from_email}>"
msg['From'] = f"Unitra-Klub <{smtp_config['user'] or 'unitra@unitraklub.pl'}>"
msg['To'] = user['mail']
msg['Subject'] = "Twoje konto w unitraklub.pl"
body = template.replace("@user", user['name']) \
.replace("@rejestracja", datetime.fromtimestamp(user['created']).strftime('%Y-%m-%d')) \
.replace("@ostatnie_logowanie", datetime.fromtimestamp(user['access']).strftime('%Y-%m-%d') if user['access'] else 'nigdy')
body = template.replace("@user", user.get('name', 'Użytkowniku')) \
.replace("@rejestracja", datetime.fromtimestamp(reg_date).strftime('%Y-%m-%d') if reg_date else 'nieznana') \
.replace("@ostatnie_logowanie", datetime.fromtimestamp(last_login).strftime('%Y-%m-%d') if last_login else 'nigdy')
msg.attach(MIMEText(body, 'html'))
smtp.send_message(msg)
@ -328,7 +329,7 @@ def main():
type=str,
help="Zakres dni nieaktywności w formacie min-max, np. 360-1825 (tylko dla wysyłki maili)"
)
args = parser.parse_args()
inactive_range = None