Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Send email with attachment, which is stored on server

Started by Muut Archive 10 years ago · 3 replies · 449 views
10 years ago

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.

10 years ago

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

10 years ago

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...

10 years ago

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.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1350 9 years ago
Archive · by Muut Archive, 9 years ago
2 934 9 years ago
Archive · by Muut Archive, 9 years ago
2 4060 9 years ago
Archive · by Muut Archive, 9 years ago
1 2947 9 years ago
Archive · by Muut Archive, 9 years ago
3 1118 9 years ago