Attaching a file from location on the server to an email

I want to attach a file (not on the File Manager) from the server.
I have the file’s absolute path.
I want to skip a stage where the user copies the file to his\her computer, just to reupload to the server into the “/files” folder and attach it to the email.
Can I “intercept” sending an email by attaching the file to it?
I know I can adapt the source code of the framework to do this, but I wish to have the frappe framework as “vanilla” as possible, while adding the functionality myself.
======================Edit================
OR…
Perhaps a file from the library… :thinking:

Found a solution (assuming the file path is at /files/subfolder/):

import os
f_url = 'frontend/public/files/subfolder/' + serial_num + '.pdf'
doc = frappe.new_doc('File')
f_name = f_url.split("/")[-1]
doc.file_name = f_name
file_url = "/files/subfolder/" + f_name
doc.file_url = file_url
doc.insert()
name = frappe.db.get_value("File", {"file_name":f_name},'name')
frappe.db.set_value("File", name,'file_url','/files/subfolder/' + f_name)
frappe.db.set_value('Sales', serial_num,'attached_file', file_url)
frappe.db.commit()
os.remove(f_url.replace("/subfolder",""))
frappe.sendmail(
	recipients=[recipient],
	sender="<my@email.com>",
	subject=subject,
	message=mail_text,
	attachments=[{'file_url': 'subfolder/' + serial_num + '.pdf'}]
	)