4

I have a file available through an URL (need authorization). I created a mailto: link and would like to attach this file in the mail. How can I do that ?

Something like "mailto:toto@gmail.fr&attachment=site.com/file.pdf"

Charly berthet
  • 1,178
  • 5
  • 15
  • 31
  • The `mailto:` protocol doesn't support attachments. – David Apr 17 '18 at 13:08
  • https://stackoverflow.com/questions/5233556/using-mailto-to-send-email-with-an-attachment explains that this would create a security issue – Bindrid Apr 17 '18 at 13:11

2 Answers2

6

mailto: doesn't support attachments, but there are various ways you could achieve a similar effect:

  1. Link to the file in a message body

    You mentioned that the link needs authorisation, you could generate temporary urls that last 30 minutes (or more/less) which allow for downloads (users can then attach the file themselves)

  2. Send the email yourself

    Your service could send an email to your user (or on behalf of your user) with the attachment using something like Amazon SES, or Mailchimp, etc...

  3. Render your PDF into HTML

    It seems you are planning on attaching PDF files. Depending on the complexity of the PDF files, you could attempt to convert the PDF into email-friendly HTML using one of many tools, such as pdf2htmlEX or Pandoc.

Joseph Reeve
  • 460
  • 3
  • 13
3

If you're hoping for an universal solution, you can't. The mailto protocol described in the RFC 2368 tells us :

The creator of a mailto URL cannot expect the resolver of a URL to understand more than the "subject" and "body" headers.

Even though other headers might be used and understood by some mail clients, this isn't an universally compatible solution. Unless you tell your clients to open these links specifically with a specific mail client that you know supports more headers (like a hypothetical attachment header), you should consider this to not be doable.

Community
  • 1
  • 1
Kewin Dousse
  • 3,880
  • 2
  • 25
  • 46