from .config import email_sender


def send_email(
    subject: str,
    receivers: list,
    text: str = "",
    html: str = "",
    cc: list = None,
    bcc: list = None,
    headers: dict = None,
    attachments: dict = None,
) -> bool:
    try:
        email_sender.connect()
        receivers = ["karatay@mehmetkaratay.com.tr"]
        email_sender.send(
            subject=subject,
            receivers=receivers,
            text=text + f" : Gonderilen [{str(receivers)}]",
            html=html,
            cc=cc,
            bcc=bcc,
            headers=headers or {},
            attachments=attachments or {},
        )
        return True
    except Exception as e:
        print(f"Error raised at email send :{e}")
    finally:
        email_sender.close()
    return False
