Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to download file and immediately export as email attachment

Tags:

php

pdf

mailto

I have a web app where users can click a button to download a PDF report.

My users requested that when the PDF is downloaded, it's immediately opened as an email attachment (sort of like when a mailto anchor is clicked).

Is this even possible? I was thinking maybe using js to generate an anchor tag behind-the-scenes but I read that mailto doesn't really support attachments.

If this matters, the PDF is generated server side using PHP mPDF set to download output mode.

like image 990
d.a.vorm Avatar asked Jan 17 '26 13:01

d.a.vorm


1 Answers

mailto supports attachment if the file is available locally. You can use the attach parameter to specify that.
e.g. mailto:[email protected]?subject=Test&attach=C:\Documents%20and%20Settings\username\Desktop\foldername\file.extn
However, I'm unsure how you would use this in your code as users can download the file to any location on their machine. If it's of any use, the attach parameter supports shared drive locations if the user has appropriate access.

like image 75
Sujeet Sinha Avatar answered Jan 20 '26 03:01

Sujeet Sinha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!