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