How to attach blob file into HTML href=“mailto:”

前端 未结 2 817
生来不讨喜
生来不讨喜 2021-01-21 02:07

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

相关标签:
2条回答
  • 2021-01-21 02:26

    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.

    0 讨论(0)
  • 2021-01-21 02:43

    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.

    0 讨论(0)
提交回复
热议问题