Filename specification

I currently have a textarea field in my form, which accepts public ssh keys. On submission, the form is then saved in a file and also emailed to me. I would like to modify it such that the contents of the textarea is saved as a separate file and preferably sent to me as an attachment of the email. Is there an easy way to achieve this?

Alternatively, I’d be happy to change textarea to file, but then I’d like the file to be renamed such that it corresponds to the form data - and again, attached to the email, if possible.

Any help or pointers would be appreciated!

I’ve just found user/plugins/form/classes/form.php, I reckon the solution is hidden somewhere in there.