0

发送多部分/替代电子邮件时,正文为空:

m = send_mail
=> <Mail::Message:70121014358060, Multipart: true, Headers: <Date: Tue, 06 Nov 2012 09:18:06
-0800>, <From: foo@example.com>, <To: bar@example.com>, 
<Message-ID: <5099464e821ef_71113fc654c35xe065537@Air.local.mail>>, <Subject: 
Test>, <Mime-Version: 1.0>, <Content-Type: 
multipart/alternative; boundary="--==_mimepart_5099422e825b0_71113fc654c34ce068277";
charset=UTF-8>, <Content-Transfer-Encoding: 7bit>>

m.body
=>

如何检查身体或不同部位?

导轨 3.2.2

4

1 回答 1

2

来自https://github.com/mikel/mail

mail = Mail.read('multipart_email')

mail.multipart?          #=> true
mail.parts.length        #=> 2
mail.preamble            #=> "Text before the first part"
mail.epilogue            #=> "Text after the last part"
mail.parts.map { |p| p.content_type }  #=> ['text/plain', 'application/pdf']
mail.parts.map { |p| p.class }         #=> [Mail::Message, Mail::Message]
mail.parts[0].content_type_parameters  #=> {'charset' => 'ISO-8859-1'}
mail.parts[1].content_type_parameters  #=> {'name' => 'my.pdf'}
于 2012-11-06T19:10:31.110 回答