from redmail import EmailSender
from config_isbank import Config


email_sender = EmailSender(
    host=Config.EMAIL_HOST,
    port=993,
    username=Config.EMAIL_USERNAME,
    password=Config.EMAIL_PASSWORD,
)


def mail_sender_service(subject, list_of_read_attachment_names):
    email_sender.connect()
    try:
        email_sender.send(
            subject=subject,
            receivers=Config.INFO_MAIL,
            text=f"Dear Admin, Hi I have read xlx files with names. {" ".join(list_of_read_attachment_names)}",
        )
        return True
    except Exception as e:
        err = e
        print("Mail send error raised : ", err)
    return False
