How to call customize python function for sending mail in case of failure of task in Airflow

I have written a send_email.py python script, which runs perfectly fine. The airflow version is 2.5.0

How to call this function in the send_email.py script of DAG so that above function triggers with required DAG_ID, RUN_ID, LOG_URL, TASK_ID

Can anyone help with this as my current version is 2.5.0

BELOW is the send_email.py

import requests
from airflow.utils.email import send_email

APITOKAN = ‘abcdefghijklmnop’
SUBJECT = ‘Airflow Testing Mail’
FROM = ‘user@domain.com’
REPLAY_TO = ‘user@domain.com’
TO = ‘firstname.lastname@domain.com’
URL = ‘https://email.domain-apps.com/email-service/smtp/sendmail

def send_email(MSG):
try:
print(‘Email function start…!’)
ApiTokan = APITOKAN
url = URL
payload = {‘subject’: SUBJECT,
‘from’: FROM,
‘replyTo’: REPLAY_TO,
‘html’: MSG,
‘to’: TO
}
headers = {
“email-api-key”: ApiTokan,
}

    response = requests.request("POST", url, json=payload, headers=headers, verify=None)
    print(response.status_code)

    print('Email Function END')

except Exception as ex:
    print('exception from function triggered...!')
    print(ex)