Skip to content

Commit

Permalink
rfc822 attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
ahorek committed Apr 21, 2020
1 parent 8fbb17d commit c0dfe57
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/mail/attachments_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ def initialize(parts_list)
@content_disposition_type = 'attachment'
parts_list.map { |p|
if p.mime_type == 'message/rfc822'
Mail.new(p.body.encoded).attachments
parts = []
parts << p if p.attachment?
parts.concat Mail.new(p.body.encoded).attachments
elsif p.parts.empty?
p if p.attachment?
else
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
From: [email protected]
To: [email protected]
Subject: test
Date: Tue, 21 Apr 2020 15:40:22 +0200 (CEST)
Message-Id: <[email protected]>
Mime-Version: 1.0
Content-Type: multipart/mixed;
boundary="------=_MB7A4C516C-8688-4B63-8C13-CC0B5BA90B2B"
Content-Transfer-Encoding: 7bit

--------=_MB7A4C516C-8688-4B63-8C13-CC0B5BA90B2B
Content-Type: multipart/related;
boundary="------=_MB7DFCF053-5DBC-4ABA-BA34-0A2FA19EC02A"
Content-Transfer-Encoding: 7bit
--------=_MB7DFCF053-5DBC-4ABA-BA34-0A2FA19EC02A
Content-Type: multipart/alternative;
boundary="------=_MB41C5AACC-67CF-4DFC-A53A-865270BC750F"
Content-Transfer-Encoding: 7bit
--------=_MB41C5AACC-67CF-4DFC-A53A-865270BC750F
Content-Type: text/html;
charset=utf-8
Content-Transfer-Encoding: quoted-printable

<html><body><img src=3D"cid:emedfeb92f-a786-4718-a446-98db8afb53fb@kronos=
" /></body></html>=


--------=_MB41C5AACC-67CF-4DFC-A53A-865270BC750F--

--------=_MB7DFCF053-5DBC-4ABA-BA34-0A2FA19EC02A
Content-Type: image/png;
name=img.png
Content-Transfer-Encoding: base64
Content-Disposition: inline;
size=370;
filename=img.png
Content-ID: <emedfeb92f-a786-4718-a446-98db8afb53fb@kronos>
iVBORw0KGgoAAAANSUhEUgAAACoAAAAgCAIAAADrOn1qAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAB
JElEQVRIx+2WzYmFMBDHs2FPQu4hTXiwBSFV2MU0IaagxBoiaA+CAbGFuAcXCb4nG/Nenizkf5CB
GfklmQ8GrXdIa70ZGN2qhE/4hP9Dxpgz1zAMcfFKqaqqlFJPXQDQNE0svDFGCIEQEkIcTqCU2lxt
2wa8gReeUgoAm+2eYGcjhAAgz/Or+G/POM75xt6/rgEAW8BVfa3r6h/tXndXALvruqIoLjce53zP
wov3/odj5/HxH3shFv5Q5097IVblH9h7vt1eCCiCa2PnwHYrUQgRMno9tzMpZVmWUsozV13XAbse
8v9nmqYzV9/30VdNSumZK2DcpnUj4T8uay3G+Db8siyEkBvw1tp5nsdxZIz9rhta689lGmNCCGMs
y7KQbeft+gGA2/AdlcTEpAAAAABJRU5ErkJggg==
--------=_MB7DFCF053-5DBC-4ABA-BA34-0A2FA19EC02A--

--------=_MB7A4C516C-8688-4B63-8C13-CC0B5BA90B2B
Content-Type: message/rfc822;
name=Testmail.eml
Content-Disposition: attachment;
filename=Testmail.eml
From [email protected] Tue May 10 11:28:07 2005
Return-Path: <[email protected]>
X-Original-To: [email protected]
Delivered-To: [email protected]
Received: from localhost (localhost [127.0.0.1])
by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F
for <[email protected]>; Tue, 10 May 2005 17:26:50 +0000 (GMT)
Received: from xxx.xxxxx.com ([127.0.0.1])
by localhost (xxx.xxxxx.com [127.0.0.1]) (amavisd-new, port 10024)
with LMTP id 70060-03 for <[email protected]>;
Tue, 10 May 2005 17:26:49 +0000 (GMT)
Received: from xxx.xxxxx.com (xxx.xxxxx.com [69.36.39.150])
by xxx.xxxxx.com (Postfix) with ESMTP id 8B957A94B
for <[email protected]>; Tue, 10 May 2005 17:26:48 +0000 (GMT)
Received: from xxx.xxxxx.com (xxx.xxxxx.com [64.233.184.203])
by xxx.xxxxx.com (Postfix) with ESMTP id 9972514824C
for <[email protected]>; Tue, 10 May 2005 12:26:40 -0500 (CDT)
Received: by xxx.xxxxx.com with SMTP id 68so1694448wri
for <[email protected]>; Tue, 10 May 2005 10:26:40 -0700 (PDT)
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws;
s=beta; d=xxxxx.com;
h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type;
b=g8ZO5ttS6GPEMAz9WxrRk9+9IXBUfQIYsZLL6T88+ECbsXqGIgfGtzJJFn6o9CE3/HMrrIGkN5AisxVFTGXWxWci5YA/7PTVWwPOhJff5BRYQDVNgRKqMl/SMttNrrRElsGJjnD1UyQ/5kQmcBxq2PuZI5Zc47u6CILcuoBcM+A=
Received: by 10.54.96.19 with SMTP id t19mr621017wrb;
Tue, 10 May 2005 10:26:39 -0700 (PDT)
Received: by 10.54.110.5 with HTTP; Tue, 10 May 2005 10:26:39 -0700 (PDT)
Message-ID: <[email protected]>
Date: Tue, 10 May 2005 11:26:39 -0600
From: Test Tester <[email protected]>
Reply-To: Test Tester <[email protected]>
To: [email protected], [email protected]
Subject: Another PDF
Mime-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_2192_32400445.1115745999735"
X-Virus-Scanned: amavisd-new at textdrive.com
--------=_MB7A4C516C-8688-4B63-8C13-CC0B5BA90B2B--
11 changes: 9 additions & 2 deletions spec/mail/attachments_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,15 @@ def check_decoded(actual, expected)

it "should find attachments inside parts with content-type message/rfc822" do
mail = read_fixture('emails/attachment_emails/attachment_message_rfc822.eml')
expect(mail.attachments.length).to eq 1
expect(mail.attachments[0].decoded.length).to eq 1026
expect(mail.attachments.length).to eq 2
expect(mail.attachments[1].decoded.length).to eq 1026
end

it "should include content-type message/rfc822 as an attachment" do
mail = read_fixture('emails/attachment_emails/attachment_message_rfc822_inline_image.eml')
expect(mail.attachments.length).to eq 2
expect(mail.attachments[1].decoded.length).to eq 1815
expect(mail.attachments[0].inline?).to eq(true)
end

it "attach filename decoding (issue 83)" do
Expand Down

0 comments on commit c0dfe57

Please sign in to comment.