Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline images aren't displaying inline #57

Open
brentkearney opened this issue Oct 10, 2018 · 1 comment
Open

Inline images aren't displaying inline #57

brentkearney opened this issue Oct 10, 2018 · 1 comment

Comments

@brentkearney
Copy link

brentkearney commented Oct 10, 2018

Hi, thanks so much for your work on sparkpost_rails!

I'm trying to include inline images like this:

message[:attachments].each do |ad|
  attachments.inline[ad.original_filename] = {
     mime_type: ad.content_type,
     content: File.read(ad.tempfile),
     cid: 'some-name'
  }
end

However, the message arrives with a randomly generated Content-Id rather than the specified cid: parameter, and a missing image icon appears where the <img> tag is in HTML, with the attachment at the bottom of the message.

In this case, the email is received from Sparkpost webhook, so the content-id is already set in the incoming email. I parse it out, and then use that value in the cid: parameter in attachments.inline[] = {}. If it were actually used, the image would display inline where specified by the <img> tag, but the cid parameter seems to be ignored.

@brentkearney
Copy link
Author

brentkearney commented Oct 10, 2018

I figured it out. To specify the Content-Id, use:

attachments.inline[filename].header['content-id'] = your-custom-id

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant