Prudvireddy commited on
Commit
51b035c
1 Parent(s): c88d358

Update tools.py

Browse files
Files changed (1) hide show
  1. tools.py +11 -3
tools.py CHANGED
@@ -350,10 +350,11 @@ def remove_temp_files(directory):
350
  # remove_temp_files('/tmp')
351
 
352
  import smtplib
353
- from email.mime.text import MIMEText
354
  from email.mime.multipart import MIMEMultipart
 
355
  from email.mime.base import MIMEBase
356
  from email import encoders
 
357
 
358
  def send_mail(user_mail, video_path):
359
  # Email configuration
@@ -373,7 +374,7 @@ def send_mail(user_mail, video_path):
373
  <html>
374
  <body>
375
  <p>Hello,<br>
376
- Thankyou for using ShortsIn.
377
  </p>
378
  </body>
379
  </html>
@@ -398,7 +399,11 @@ def send_mail(user_mail, video_path):
398
  msg.attach(part)
399
  else:
400
  print(f"Error: The file {video_path} does not exist.")
 
401
 
 
 
 
402
  # Connect to the SMTP server
403
  try:
404
  server = smtplib.SMTP('smtp.gmail.com', 587) # Example SMTP server and port
@@ -409,4 +414,7 @@ def send_mail(user_mail, video_path):
409
  except Exception as e:
410
  print(f'Error sending email: {str(e)}')
411
  finally:
412
- server.quit()
 
 
 
 
350
  # remove_temp_files('/tmp')
351
 
352
  import smtplib
 
353
  from email.mime.multipart import MIMEMultipart
354
+ from email.mime.text import MIMEText
355
  from email.mime.base import MIMEBase
356
  from email import encoders
357
+ import os
358
 
359
  def send_mail(user_mail, video_path):
360
  # Email configuration
 
374
  <html>
375
  <body>
376
  <p>Hello,<br>
377
+ Thank you for using ShortsIn.
378
  </p>
379
  </body>
380
  </html>
 
399
  msg.attach(part)
400
  else:
401
  print(f"Error: The file {video_path} does not exist.")
402
+ return
403
 
404
+ # Initialize server variable
405
+ server = None
406
+
407
  # Connect to the SMTP server
408
  try:
409
  server = smtplib.SMTP('smtp.gmail.com', 587) # Example SMTP server and port
 
414
  except Exception as e:
415
  print(f'Error sending email: {str(e)}')
416
  finally:
417
+ if server:
418
+ server.quit()
419
+
420
+