아래 코드에서 내가 잘못하고있는 부분을 누군가가 도와 줄 수 있기를 바랬습니다. 대부분의 이메일 클라이언트 (Gmail 웹, 안드로이드),하지만 아이폰/ipad에 제대로 렌더링되지 않습니다 : HTML 콘텐츠 또는 텍스트 콘텐츠가 표시되지 않고 마지막으로 첨부 된 그림 만 표시됩니다. 모든 이메일 클라이언트가 페이로드를 다르게 해석하고 렌더링한다는 것을 이해합니다. 아이폰에서 작동하도록하는 방법을 모르겠습니다.인라인 이미지가있는 html 이메일이 iphone에서 제대로 렌더링되지 않음
도움을 주셨습니다.
루비 코드 :
require 'mail'
def inline_body_with_attachments(html, attachments)
attachments.each do |attachment|
if (html =~ /#{attachment.filename}/)
html = html.sub(attachment.filename, "cid:#{attachment.cid}")
end
end
return html
end
mail = Mail.new({
:from => "[email protected]",
:to => "[email protected]",
:subject => "html email with inline images"
})
text_part = Mail::Part.new do
body "some text"
end
mail.text_part = text_part
# Load the attachments
attachment = "image.png"
mail.attachments[attachment] = File.read(attachment)
inline_html = inline_body_with_attachments("<b>An inline image</b><img src='image.png'/>", mail.attachments)
html_part = Mail::Part.new do
content_type 'text/html; charset=UTF-8'
body inline_html
end
mail.html_part = html_part
mail.deliver!
같은 이메일 보이는이 도움이 경우 잘 모르겠어요,하지만 난 꽤 많은 코드를 따라, 그리고 내 아이폰에서 작동
Date: Fri, 24 May 2013 13:58:02 +0000
From: [email protected]
To: [email protected]
Message-ID: <[email protected]>
Subject: test mail with attachment- raw
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="--==_mimepart_519f71eab2260_2a1d9e076471d6";
charset=UTF-8
Content-Transfer-Encoding: 7bit
----==_mimepart_519f71eab2260_2a1d9e076471d6
Date: Fri, 24 May 2013 13:58:02 +0000
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-ID: <[email protected]>
some text
----==_mimepart_519f71eab2260_2a1d9e076471d6
Date: Fri, 24 May 2013 13:58:02 +0000
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-ID: <[email protected]>
<b>An inline image</b><img src='cid:[email protected]'/>
----==_mimepart_519f71eab2260_2a1d9e076471d6
Date: Fri, 24 May 2013 13:58:02 +0000
Mime-Version: 1.0
Content-Type: image/png;
charset=UTF-8;
filename=image.png
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename=image.png
Content-ID: <[email protected]>
iVBORw0KGgoAAAANSUhEUgAAASwAAABaCAYAAAACcWsdAAAXUUlEQVR4nGJk
[.... more image encoding ...]
DhwFowAXGE0go2CQAAAAAAD//wMAFOkCtHNhXPkAAAAASUVORK5CYII=
----==_mimepart_519f71eab2260_2a1d9e076471d6--
나는 당신을 도울 수 없지만, 내가 해결하려고 노력했던 내 문제 중 하나에 해결책을 제공해 주신 것에 대해 감사드립니다. +1 – GoldfishGrenade
인라인 이미지도 보내려고하지만'.cid' 메쏘드를 찾을 수 없습니다. 생성 된 메쏘드 나 다른 메쏘드에 있나요? – sylvian
nevermind, 질문에 답변 [여기] (http://stackoverflow.com/questions/24273954/inline-images-with-ruby-mail-gem/24274267#24274267) – sylvian