nowy mail i funkcja
This commit is contained in:
		
							
								
								
									
										11
									
								
								app.py
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								app.py
									
									
									
									
									
								
							@@ -205,15 +205,16 @@ 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'))
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user