How to access files and send them via email? #4899
-
I have the following DB hook (it's non-functional)
but I believe this is not the right way to load attachments from the db and send in email, whats the right way to do it? My usecase is to send invoice pdfs via email that are generated once the record is created in db |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
See #4686. The Alternatively, instead of file attachment you can simply use a link to the PDF file (this will also make your mail payload smaller). The url needs to be in the format:
|
Beta Was this translation helpful? Give feedback.
No, I don't recommend this but honestly I no longer understand what you are trying todo.
The more I read you code sample the more I'm getting confused. The function callback signature to
$app.dao().findRecordById
is not correct. I don't know from where did you get thefunction(err, userRecord)
but you can check the docs in https://pocketbase.io/jsvm/classes/Dao.html#findRecordById. The same apply for thesaveRecord
function - it doesn't accept a callback argument.My recommendation is to use a simple link in your email but if that's not an option and you want a file attachment, then here is a slightly modified version of your code (I haven't tested it; treat it as a pseudo-code):
onModelA…