Birisi aşağıdaki kodda yanlış yaptığım şeyleri bana yardımcı olabilir umuyordum - e-posta gönderdim, resim çoğu e-posta istemcisinin içinde düzgün bir şekilde yazılmış (gmail web, android), ancak bir iphone/ipad üzerinde düzgün şekilde görüntülenmiyor: görüntülenen herhangi bir html içeriği veya metin içeriği olmadan yalnızca son eklenen resim görüntülenir. Her e-posta istemcisinin, yükü farklı şekilde yorumladığını ve oluşturduğunu anlıyorum, bir iphone üzerinde nasıl çalışacağımı bilmiyorum.html email with inline images iphone içinde düzgün oluşturulmamış
Herhangi bir yardım için teşekkür ederiz!
yakut kodu:
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!
gibi e-posta arar: Bu yardımcı olup olmadığından emin değilim ama ben çok fazla kodunuzu izledi ve benim iPhone'da çalışan
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--
Size yardımcı olamıyorum, ancak günlerce çözmeyi denediğim sorunlardan birine çözüm sunduğunuz için size teşekkür etmek istiyorum. +1 – GoldfishGrenade
Satır içi resimler göndermeye çalışıyorum ama '.cid' yöntemini bulamıyorum, farklı bir gemide mi yoksa oluşturulmuş ancak burada gösterilmeyen bir yöntem mi? – sylvian
nevermind, soru cevaplandı [burada] (http://stackoverflow.com/questions/24273954/inline-images-with-ruby-mail-gem/24274267#24274267) – sylvian