converting v2020 custom files to v2021

Since you want to post data to a page to send email, with v2021 it is better to use Route_Action server event instead, see Server Events and Client Scripts in the help file and:
https://discourse.hkvstore.com/t/using-route-action-server-event-v2021/3393/1