Skip to content

Instantly share code, notes, and snippets.

@endymion
Last active November 28, 2022 22:21
Show Gist options
  • Save endymion/97ddb51e61a488a5746fec4399718c4a to your computer and use it in GitHub Desktop.
Save endymion/97ddb51e61a488a5746fec4399718c4a to your computer and use it in GitHub Desktop.

Revisions

  1. endymion revised this gist Nov 28, 2022. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions change_to_line.rb
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,13 @@
    puts "To line after: "
    puts ' ' + mime_message.match(/^(To\:.*)$/)[1]

    # Remove the BCC: line.
    mime_message.gsub!(/^BCC\:.*\n/,'')
    puts "Removed BCC:"
    puts mime_message

    __END__
    BCC: [email protected]
    To: Guest <[email protected]>
    From: Some One <[email protected]>
    MIME-Version: 1.0
  2. endymion created this gist Nov 28, 2022.
    34 changes: 34 additions & 0 deletions change_to_line.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    mime_message = DATA.read

    puts "To line before: "
    puts ' ' + mime_message.match(/^(To\:.*)$/i)[1]

    # Massage the To: line.
    changed_to = '[email protected]'
    mime_message.gsub!(/^To\:.*$/i, "To: #{changed_to}")

    puts "To line after: "
    puts ' ' + mime_message.match(/^(To\:.*)$/)[1]

    __END__
    To: Guest <[email protected]>
    From: Some One <[email protected]>
    MIME-Version: 1.0
    Content-Type: multipart/mixed;
    boundary="XXXXboundary text"

    This is a multipart message in MIME format.

    --XXXXboundary text
    Content-Type: text/plain

    this is the body text

    --XXXXboundary text
    Content-Type: text/plain;
    Content-Disposition: attachment;
    filename="test.txt"

    this is the attachment text

    --XXXXboundary text--