There is an error in the script. Line that says:
email_subject = email_subject.replace(sub, str(feature.attributes[message['body substitutions'][sub]]))
This tries to replace using a field value, but you are building the URL with configured strings, not field values. It works if you change this line to say:
email_subject = email_subject.replace(sub, str(message['body substitutions'][sub]))
There is an error in the script. Line that says:
email_subject = email_subject.replace(sub, str(feature.attributes[message['body substitutions'][sub]]))
This tries to replace using a field value, but you are building the URL with configured strings, not field values. It works if you change this line to say:
email_subject = email_subject.replace(sub, str(message['body substitutions'][sub]))