Attach File Through mailto URI
Asked Answered
L

2

13

Is it possible to attach a file using "mailto:" redirect in javascript?

Something like this:

document.location = "mailto:"+recipient+"?subject="+subject+"&body="+msg+"?attach="+"file1.zip";
Loram answered 3/3, 2010 at 14:28 Comment(3)
Only if file1.zip is already on every recipients computer. I think.Segment
I intend to send a generated log file, when the user clicks on the Email icon in HTML page Is it possible ?Loram
You should just send this log file as text in body.Segment
C
22

No, you can not add an attachment to a message with the mailto: URL scheme.

mailto: only supports header values or text/plain content. See RFC 2368 for details.

Cannery answered 3/3, 2010 at 14:30 Comment(4)
+1 It clearly states on there "Only the Subject, Keywords, and Body headers are believed to be both safe and useful."Armhole
Thanks, if I have to send a file as an attachment(through program) how would you suggest do it ??Loram
@Kiran: see my answer for this.Albertalberta
This was possible on some older systems, per x.com/jensvoid/status/1295724959709437956?s=20.Sparrowgrass
A
3

You can create a custom email form, letting the user input a valid email-address if necessary and send this to the server. The server then can use a mail library to send an email including an attachment.

If you use PHP, you can easily do this using PHPMailer.

Albertalberta answered 3/3, 2010 at 14:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.