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

百般思念 提交于 2019-12-11 10:39:24

问题


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"


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/49878960/how-to-attach-blob-file-into-html-href-mailto

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!