Send email with attachment, which is stored on server

Hi guys. Need to send email with an attachment, PDF file, which is already stored on a server. In the docs there’s only how to send file which was uploaded via form… Please advise.
Or there’s no such possibility, just to grab file from server? Somehow it should be defined at ‘attachments’ section, but it’s absolutely unclear, how.
Huge thanks in advance, this feature is critical for my project.

How are you sending this email? Is this a response to a form, so is the email configured in a page header?

The task was just to send PDF to email, which user specifies in custom frontend form, made with html + js.
I ended up with using PHPMailer, creating simple script and calling it via POST AJAX request… Without reloading page or something. It appeared much easier, than all other approaches. Unfortunately, just trigger sending the email with file from server become ridiculously complicated task in scope of Grav… If you need just send it, not reload your page after form processing, as in 90s…

You can have your theme submit the form using AJAX by intercepting the submit event. The default is to use a standard POST event to the server, but nothing prevents a theme to handle this differently if needed. The default just uses the common denominator that’s available in all themes without imposing anything, as handling errors and the output can vary depending on the need of a form.

As for the attachment, this use case has not come up before, but you can create a custom form processing action that sends an email with your attachment, by copying what the Email plugin does.