logger
This commit is contained in:
@@ -6,6 +6,7 @@ import os
|
||||
import uuid
|
||||
import config
|
||||
from werkzeug.utils import secure_filename
|
||||
from app import logger
|
||||
|
||||
UPLOAD_ROOT = os.path.join(os.getcwd(), 'uploads')
|
||||
|
||||
@@ -29,17 +30,19 @@ def send_email(recipient_email, subject, body):
|
||||
server.starttls()
|
||||
server.login(sender_email, sender_password)
|
||||
server.send_message(msg)
|
||||
logger.info(f"Email sent successfully via SMTP to {recipient_email}")
|
||||
except Exception as e:
|
||||
print(f"Failed to send email via external SMTP: {e}")
|
||||
logger.error(f"Failed to send email via SMTP to {recipient_email}: {e}")
|
||||
else:
|
||||
try:
|
||||
process = os.popen(f"/usr/sbin/sendmail -t")
|
||||
process = os.popen("/usr/sbin/sendmail -t")
|
||||
process.write(f"To: {recipient_email}\n")
|
||||
process.write(f"Subject: {subject}\n")
|
||||
process.write(f"\n{body}")
|
||||
process.close()
|
||||
logger.info(f"Email sent successfully via sendmail to {recipient_email}")
|
||||
except Exception as e:
|
||||
print(f"Failed to send email via local sendmail: {e}")
|
||||
logger.error(f"Failed to send email via local sendmail to {recipient_email}: {e}")
|
||||
|
||||
def is_file_allowed(file):
|
||||
return '.' in file.filename and file.filename.rsplit('.', 1)[1].lower() in config.ALLOWED_EXTENSIONS
|
||||
|
||||
Reference in New Issue
Block a user