Skip to content

Instantly share code, notes, and snippets.

@radiospiel
Created October 26, 2016 08:38
Show Gist options
  • Save radiospiel/80b51038a3b5136082b86e58ab6fcd21 to your computer and use it in GitHub Desktop.
Save radiospiel/80b51038a3b5136082b86e58ab6fcd21 to your computer and use it in GitHub Desktop.
require "mail"
mail = Mail.new do
to 'nicolas@test.lindsaar.net.au'
from 'Mikel Lindsaar <mikel@test.lindsaar.net.au>'
subject 'First multipart email sent with Mail'
text_part do
body 'Find my source code attached'
end
html_part do
content_type 'text/html; charset=UTF-8'
body 'Find my <b>source code</b> attached'
end
end
mail.add_file(__FILE__)
puts mail.to_s
@radiospiel
Copy link
Author

Produces

Date: Wed, 26 Oct 2016 08:37:48 +0000
From: Mikel Lindsaar <mikel@test.lindsaar.net.au>
To: nicolas@test.lindsaar.net.au
Message-ID: <58106b5cd50f9_24ca3f8711963124631fa@devbox.mail>
Subject: First multipart email sent with Mail
Mime-Version: 1.0
Content-Type: multipart/alternative;
 boundary="--==_mimepart_58106b5cd10dd_24ca3f8711963124630c0";
 charset=UTF-8
Content-Transfer-Encoding: 7bit


----==_mimepart_58106b5cd10dd_24ca3f8711963124630c0
Content-Type: text/plain;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

Find my source code attached
----==_mimepart_58106b5cd10dd_24ca3f8711963124630c0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

Find my <b>source code</b> attached
----==_mimepart_58106b5cd10dd_24ca3f8711963124630c0
Content-Type: application/x-ruby;
 charset=UTF-8;
 filename=mt.rb
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename=mt.rb
Content-ID: <58106b5cd5f31_24ca3f8711963124632f1@devbox.mail>

cmVxdWlyZSAibWFpbCIKCm1haWwgPSBNYWlsLm5ldyBkbwogIHRvICAgICAg
J25pY29sYXNAdGVzdC5saW5kc2Fhci5uZXQuYXUnCiAgZnJvbSAgICAnTWlr
ZWwgTGluZHNhYXIgPG1pa2VsQHRlc3QubGluZHNhYXIubmV0LmF1PicKICBz
dWJqZWN0ICdGaXJzdCBtdWx0aXBhcnQgZW1haWwgc2VudCB3aXRoIE1haWwn
CgogIHRleHRfcGFydCBkbwogICAgYm9keSAnRmluZCBteSBzb3VyY2UgY29k
ZSBhdHRhY2hlZCcKICBlbmQKCiAgaHRtbF9wYXJ0IGRvCiAgICBjb250ZW50
X3R5cGUgJ3RleHQvaHRtbDsgY2hhcnNldD1VVEYtOCcKICAgIGJvZHkgJ0Zp
bmQgbXkgPGI+c291cmNlIGNvZGU8L2I+IGF0dGFjaGVkJwogIGVuZAplbmQK
Cm1haWwuYWRkX2ZpbGUoX19GSUxFX18pCgpwdXRzIG1haWwudG9fcwo=

----==_mimepart_58106b5cd10dd_24ca3f8711963124630c0--

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment