Compare commits

...

3 Commits
main ... mail

  1. 2
      padelclub_backend/settings_app.py
  2. 12
      tournaments/views.py

@ -27,7 +27,7 @@ EMAIL_PORT = 587
EMAIL_HOST_USER = 'xlr@alwaysdata.net' EMAIL_HOST_USER = 'xlr@alwaysdata.net'
EMAIL_HOST_PASSWORD = 'XLRSport$2024' EMAIL_HOST_PASSWORD = 'XLRSport$2024'
EMAIL_USE_TLS = True EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'Padel Club <xlr@alwaysdata.net>' DEFAULT_FROM_EMAIL = 'razmig@padelclub.app'
CACHES = { CACHES = {
'default': { 'default': {

@ -438,7 +438,7 @@ def simple_form_view(request):
def send_email_to_jap_list(): def send_email_to_jap_list():
# Open the CSV file # Open the CSV file
with open('tournaments/static/misc/jap-test.csv', 'r') as file: with open('tournaments/static/misc/jap-liste2.csv', 'r') as file:
csv_reader = csv.reader(file) csv_reader = csv.reader(file)
def log_error(message): def log_error(message):
@ -446,6 +446,11 @@ def send_email_to_jap_list():
timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S') timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
log_file.write(f"{timestamp}: {message}\n") log_file.write(f"{timestamp}: {message}\n")
def log_progress(batch):
with open('email_progress.log', 'a') as log_file:
timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
log_file.write(f"{batch}: \n")
batch = [] batch = []
for row in csv_reader: for row in csv_reader:
if len(row) >= 4: if len(row) >= 4:
@ -453,7 +458,7 @@ def send_email_to_jap_list():
mail = row[3] mail = row[3]
batch.append((mail, name)) batch.append((mail, name))
if len(batch) == 10: if len(batch) == 5:
for email, recipient_name in batch: for email, recipient_name in batch:
try: try:
send_email(email, recipient_name) send_email(email, recipient_name)
@ -464,7 +469,8 @@ def send_email_to_jap_list():
print(error_message) print(error_message)
batch = [] batch = []
time.sleep(2) log_progress(batch)
time.sleep(3)
else: else:
print(f"Row doesn't have enough elements: {row}") print(f"Row doesn't have enough elements: {row}")

Loading…
Cancel
Save