Rails 4, Mailer preview, preview attached images

前端 未结 3 662
南笙
南笙 2021-02-15 15:39

I have problem with rails 4.1.6 mailer preview.

I want to see attached images in preview mode, but it doesn\'t work. I think it\'s incorrect

There is my code:

3条回答
  •  野性不改
    2021-02-15 16:02

    You're not doing anything wrong; it's a shortcoming in the way the Rails Mail Previewer is designed.

    The Rails Mailer code, reasonably, generates URLs for attachments that reference mail "parts" in a multipart email. The "cid" in the URL for your tag refers to the "content ID" of the particular part/attachment. This is how URLs within an email work.

    However, the previewer controller isn't rendering in the context of an email client: it's a standard web browser. There is no "cid" URL protocol scheme, and no multi-part email to reference (it's all just standard HTML documents). Rails::MailersController currently isn't smart enough to realize this, and just renders the email as-is.

    To make this work, it'd have to detect all references to cid: URLs and replace them with regular http: URLs back to itself, then return the content for the various attachments.

    There's an open issue on GitHub/rails to do this, but as of yet it's not complete.

提交回复
热议问题