Good day,
I can help you with your script and the issue with DKIM validation. I've plenty experience, im a sysadmin since more than 19 years and i faced this kind of problems.
Hablo español, soy de México.
This can be fixed within today, feel free to contact me if you need to solve any questions.
Best regards.