Last active
April 16, 2018 12:12
-
-
Save skalee/f724b3c69657aa0b836a9208b2505af1 to your computer and use it in GitHub Desktop.
Mail transport encoding is difficult to set - Pry session
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[5] pry(main)> Mail::VERSION.version | |
=> "2.7.0" | |
[6] pry(main)> part = Mail::Part.new | |
=> #<Mail::Part:70253998469580, Multipart: false, Headers: <Content-Type: text/plain>> | |
[7] pry(main)> part.body = "Whatever" | |
=> "Whatever" | |
[8] pry(main)> puts part.encoded | |
Content-Type: text/plain; | |
charset=UTF-8 | |
Content-Transfer-Encoding: 7bit | |
Whatever | |
=> nil | |
[9] pry(main)> part.content_transfer_encoding = "quoted-printable" | |
=> "quoted-printable" | |
[10] pry(main)> part | |
=> #<Mail::Part:70253998469580, Multipart: false, Headers: <Content-Type: text/plain>, <Content-Transfer-Encoding: quoted-printable>> | |
[11] pry(main)> puts part.encoded | |
Content-Type: text/plain; | |
charset=UTF-8 | |
Content-Transfer-Encoding: 7bit | |
Whatever | |
=> nil | |
[12] pry(main)> part | |
=> #<Mail::Part:70253998469580, Multipart: false, Headers: <Content-Type: text/plain>, <Content-Transfer-Encoding: 7bit>> | |
[13] pry(main)> part.transport_encoding = "quoted-printable" | |
=> "quoted-printable" | |
[14] pry(main)> part | |
=> #<Mail::Part:70253998469580, Multipart: false, Headers: <Content-Type: text/plain>, <Content-Transfer-Encoding: 7bit>> | |
[16] pry(main)> puts part.encoded | |
Content-Type: text/plain; | |
charset=UTF-8 | |
Content-Transfer-Encoding: quoted-printable | |
Whatever= | |
=> nil | |
[17] pry(main)> outer = Mail::Part.new | |
=> #<Mail::Part:70254001654700, Multipart: false, Headers: <Content-Type: text/plain>> | |
[18] pry(main)> outer.add_part part | |
=> [#<Mail::Part:70253998469580, Multipart: false, Headers: <Content-Type: text/plain>, <Content-Transfer-Encoding: quoted-printable>>] | |
[19] pry(main)> puts outer.encoded | |
Content-Type: text/plain; | |
boundary="--==_mimepart_5ad492b173aaf_27603fe548842e5852040"; | |
charset=UTF-8 | |
Content-Transfer-Encoding: 7bit | |
----==_mimepart_5ad492b173aaf_27603fe548842e5852040 | |
Content-Type: text/plain; | |
charset=UTF-8 | |
Content-Transfer-Encoding: 7bit | |
Whatever | |
----==_mimepart_5ad492b173aaf_27603fe548842e5852040-- | |
=> nil | |
[20] pry(main)> part.body.encoding = "quoted-printable" | |
=> "quoted-printable" | |
[21] pry(main)> part | |
=> #<Mail::Part:70253998469580, Multipart: false, Headers: <Content-Type: text/plain>, <Content-Transfer-Encoding: 7bit>> | |
[22] pry(main)> part.body | |
=> #<Mail::Body:0x00007fca919aad68 | |
@ascii_only=true, | |
@boundary=nil, | |
@charset="US-ASCII", | |
@encoding="quoted-printable", | |
@epilogue=nil, | |
@part_sort_order=["text/plain", "text/enriched", "text/html", "multipart/alternative"], | |
@parts=[], | |
@preamble=nil, | |
@raw_source="Whatever"> | |
[23] pry(main)> puts part.encoded | |
Content-Type: text/plain; | |
charset=UTF-8 | |
Content-Transfer-Encoding: quoted-printable | |
Whatever= | |
=> nil | |
[24] pry(main)> puts outer.encoded | |
Content-Type: text/plain; | |
boundary="--==_mimepart_5ad492b173aaf_27603fe548842e5852040"; | |
charset=UTF-8 | |
Content-Transfer-Encoding: 7bit | |
----==_mimepart_5ad492b173aaf_27603fe548842e5852040 | |
Content-Type: text/plain; | |
charset=UTF-8 | |
Content-Transfer-Encoding: quoted-printable | |
Whatever= | |
----==_mimepart_5ad492b173aaf_27603fe548842e5852040-- | |
=> nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment