helpyio/helpy

View on GitHub

Showing 242 of 242 total issues

Expected '===' and instead saw '=='.
Open

    if (chosen == 'imap' ){
Severity: Minor
Found in app/assets/javascripts/admin.js by eslint

Require === and !== (eqeqeq)

It is considered good practice to use the type-safe equality operators === and !== instead of their regular counterparts == and !=.

The reason for this is that == and != do type coercion which follows the rather obscure Abstract Equality Comparison Algorithm. For instance, the following statements are all considered true:

  • [] == false
  • [] == ![]
  • 3 == "03"

If one of those occurs in an innocent-looking statement such as a == b the actual problem is very difficult to spot.

Rule Details

This rule is aimed at eliminating the type-unsafe equality operators.

Examples of incorrect code for this rule:

/*eslint eqeqeq: "error"*/

if (x == 42) { }

if ("" == text) { }

if (obj.getStuff() != undefined) { }

The --fix option on the command line automatically fixes some problems reported by this rule. A problem is only fixed if one of the operands is a typeof expression, or if both operands are literals with the same type.

Options

always

The "always" option (default) enforces the use of === and !== in every situation (except when you opt-in to more specific handling of null [see below]).

Examples of incorrect code for the "always" option:

/*eslint eqeqeq: ["error", "always"]*/

a == b
foo == true
bananas != 1
value == undefined
typeof foo == 'undefined'
'hello' != 'world'
0 == 0
true == true
foo == null

Examples of correct code for the "always" option:

/*eslint eqeqeq: ["error", "always"]*/

a === b
foo === true
bananas !== 1
value === undefined
typeof foo === 'undefined'
'hello' !== 'world'
0 === 0
true === true
foo === null

This rule optionally takes a second argument, which should be an object with the following supported properties:

  • "null": Customize how this rule treats null literals. Possible values:
    • always (default) - Always use === or !==.
    • never - Never use === or !== with null.
    • ignore - Do not apply this rule to null.

smart

The "smart" option enforces the use of === and !== except for these cases:

  • Comparing two literal values
  • Evaluating the value of typeof
  • Comparing against null

Examples of incorrect code for the "smart" option:

/*eslint eqeqeq: ["error", "smart"]*/

// comparing two variables requires ===
a == b

// only one side is a literal
foo == true
bananas != 1

// comparing to undefined requires ===
value == undefined

Examples of correct code for the "smart" option:

/*eslint eqeqeq: ["error", "smart"]*/

typeof foo == 'undefined'
'hello' != 'world'
0 == 0
true == true
foo == null

allow-null

Deprecated: Instead of using this option use "always" and pass a "null" option property with value "ignore". This will tell eslint to always enforce strict equality except when comparing with the null literal.

["error", "always", {"null": "ignore"}]

When Not To Use It

If you don't want to enforce a style for using equality operators, then it's safe to disable this rule. Source: http://eslint.org/docs/rules/

TODO found
Open

      # TODO: Refactor this to use an index method/view on the users model

TODO found
Open

  # TODO: Will want to refactor this using .or when upgrading to Rails 5
Severity: Minor
Found in app/models/user.rb by fixme

TODO found
Open

            tracker("Agent: #{current_user.name}", "Agent Replied", @topic.to_param) #TODO: Need minutes

TODO found
Open

            tracker("Agent: #{agent.name}", "User Replied", @topic.to_param) #TODO: Need minutes
Severity: Minor
Found in app/controllers/posts_controller.rb by fixme

TODO found
Open

            tracker("Agent: #{current_user.name}", "Agent Posted Note", @topic.to_param) #TODO: Need minutes

TODO found
Open

  # TODO: Resolve the following violations
Severity: Minor
Found in .scss-lint.yml by fixme

TODO found
Open

gem "omniauth-rails_csrf_protection" # TODO: remove once https://github.com/omniauth/omniauth/pull/809 is resolved
Severity: Minor
Found in Gemfile by fixme

TODO found
Open

mail,2.7.1,https://github.com/mikel/mail,MIT,http://opensource.org/licenses/mit-license,"Copyright (c) 2009-2016 Mikel Lindsaar\@NLPermission is hereby granted, free of charge, to any person obtaining\@NLa copy of this software and associated documentation files (the\@NL'Software'), to deal in the Software without restriction, including\@NLwithout limitation the rights to use, copy, modify, merge, publish,\@NLdistribute, sublicense, and/or sell copies of the Software, and to\@NLpermit persons to whom the Software is furnished to do so, subject to\@NLthe following conditions:\@NLThe above copyright notice and this permission notice shall be\@NLincluded in all copies or substantial portions of the Software.\@NLTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\@NLEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\@NLMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\@NLIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\@NLCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\@NLTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\@NLSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\@NL# Mail [![Build Status](https://travis-ci.org/mikel/mail.png?branch=master)](https://travis-ci.org/mikel/mail)\@NL## Introduction\@NLMail is an internet library for Ruby that is designed to handle emails\@NLgeneration, parsing and sending in a simple, rubyesque manner.\@NLThe purpose of this library is to provide a single point of access to handle\@NLall email functions, including sending and receiving emails.  All network\@NLtype actions are done through proxy methods to Net::SMTP, Net::POP3 etc.\@NLBuilt from my experience with TMail, it is designed to be a pure ruby\@NLimplementation that makes generating, sending and parsing emails a no\@NLbrainer.\@NLIt is also designed from the ground up to work with the more modern versions\@NLof Ruby.  This is because Ruby > 1.9 handles text encodings much more wonderfully\@NLthan Ruby 1.8.x and so these features have been taken full advantage of in this\@NLlibrary allowing Mail to handle a lot more messages more cleanly than TMail.\@NLMail does run on Ruby 1.8.x... it's just not as fun to code.\@NLFinally, Mail has been designed with a very simple object oriented system\@NLthat really opens up the email messages you are parsing, if you know what\@NLyou are doing, you can fiddle with every last bit of your email directly.\@NL## Donations\@NLMail has been downloaded millions of times, by people around the world, in fact,\@NLit represents more than 1% of *all* gems downloaded.\@NLIt is (like all open source software) a labour of love and something I am doing\@NLwith my own free time.  If you would like to say thanks, please feel free to\@NL[make a donation](http://www.pledgie.com/campaigns/8790) and feel free to send\@NLme a nice email :)\@NL<a href='http://www.pledgie.com/campaigns/8790'><img alt='Click here to lend your support to: mail and make a donation at www.pledgie.com !' src='http://www.pledgie.com/campaigns/8790.png?skin_name=chrome' border='0' /></a>\@NL# Contents\@NL* [Compatibility](#compatibility)\@NL* [Discussion](#discussion)\@NL* [Current Capabilities of Mail](#current-capabilities-of-mail)\@NL* [Roadmap](#roadmap)\@NL* [Testing Policy](#testing-policy)\@NL* [API Policy](#api-policy)\@NL* [Installation](#installation)\@NL* [Encodings](#encodings)\@NL* [Contributing](#contributing)\@NL* [Usage](#usage)\@NL* [Core Extensions](#core-extensions)\@NL* [Excerpts from TREC Span Corpus 2005](#excerpts-from-trec-span-corpus-2005)\@NL* [License](#license)\@NL## Compatibility\@NLMail supports Ruby 1.8.7+, including JRuby and Rubinius.\@NLEvery Mail commit is tested by Travis on [all supported Ruby versions](https://github.com/mikel/mail/blob/master/.travis.yml).\@NL## Discussion\@NLIf you want to discuss mail with like minded individuals, please subscribe to\@NLthe [Google Group](http://groups.google.com/group/mail-ruby).\@NL## Current Capabilities of Mail\@NL* RFC5322 Support, Reading and Writing\@NL* RFC6532 Support, reading UTF-8 headers\@NL* RFC2045-2049 Support for multipart emails\@NL* Support for creating multipart alternate emails\@NL* Support for reading multipart/report emails &amp; getting details from such\@NL* Wrappers for File, Net/POP3, Net/SMTP\@NL* Auto-encoding of non-US-ASCII bodies and header fields\@NLMail is RFC5322 and RFC6532 compliant now, that is, it can parse US-ASCII and UTF-8\@NLemails and generate US-ASCII emails. There are a few obsoleted syntax emails that\@NLit will have problems with, but it also is quite robust, meaning, if it finds something\@NLit doesn't understand it will not crash, instead, it will skip the problem and keep\@NLparsing. In the case of a header it doesn't understand, it will initialise the header\@NLas an optional unstructured field and continue parsing.\@NLThis means Mail won't (ever) crunch your data (I think).\@NLYou can also create MIME emails.  There are helper methods for making a\@NLmultipart/alternate email for text/plain and text/html (the most common pair)\@NLand you can manually create any other type of MIME email.\@NL## Roadmap\@NLNext TODO:\@NL* Improve MIME support for character sets in headers, currently works, mostly, needs\@NL  refinement.\@NL## Testing Policy\@NLBasically... we do BDD on Mail.  No method gets written in Mail without a\@NLcorresponding or covering spec.  We expect as a minimum 100% coverage\@NLmeasured by RCov.  While this is not perfect by any measure, it is pretty\@NLgood.  Additionally, all functional tests from TMail are to be passing before\@NLthe gem gets released.\@NLIt also means you can be sure Mail will behave correctly.\@NLNote: If you care about core extensions (aka ""monkey-patching""), please read the Core Extensions section near the end of this README.\@NL## API Policy\@NLNo API removals within a single point release.  All removals to be deprecated with\@NLwarnings for at least one MINOR point release before removal.\@NLAlso, all private or protected methods to be declared as such - though this is still I/P.\@NL## Installation\@NLInstallation is fairly simple, I host mail on rubygems, so you can just do:\@NL    # gem install mail\@NL## Encodings\@NLIf you didn't know, handling encodings in Emails is not as straight forward as you\@NLwould hope.\@NLI have tried to simplify it some:\@NL1. All objects that can render into an email, have an `#encoded` method.  Encoded will\@NL   return the object as a complete string ready to send in the mail system, that is,\@NL   it will include the header field and value and CRLF at the end and wrapped as\@NL   needed.\@NL2. All objects that can render into an email, have a `#decoded` method.  Decoded will\@NL   return the object's ""value"" only as a string.  This means it will not include\@NL   the header fields (like 'To:' or 'Subject:').\@NL3. By default, calling <code>#to_s</code> on a container object will call its encoded\@NL   method, while <code>#to_s</code> on a field object will call its decoded method.\@NL   So calling <code>#to_s</code> on a Mail object will return the mail, all encoded\@NL   ready to send, while calling <code>#to_s</code> on the From field or the body will\@NL   return the decoded value of the object. The header object of Mail is considered a\@NL   container. If you are in doubt, call <code>#encoded</code>, or <code>#decoded</code>\@NL   explicitly, this is safer if you are not sure.\@NL4. Structured fields that have parameter values that can be encoded (e.g. Content-Type) will\@NL   provide decoded parameter values when you call the parameter names as methods against\@NL   the object.\@NL5. Structured fields that have parameter values that can be encoded (e.g. Content-Type) will\@NL   provide encoded parameter values when you call the parameter names through the\@NL   <code>object.parameters['<parameter_name>']</code> method call.\@NL## Contributing\@NLPlease do!  Contributing is easy in Mail.  Please read the CONTRIBUTING.md document for more info\@NL## Usage\@NLAll major mail functions should be able to happen from the Mail module.\@NLSo, you should be able to just <code>require 'mail'</code> to get started.\@NL### Making an email\@NL```ruby\@NLmail = Mail.new do\@NL  from    'mikel@test.lindsaar.net'\@NL  to      'you@test.lindsaar.net'\@NL  subject 'This is a test email'\@NL  body    File.read('body.txt')\@NLend\@NLmail.to_s #=> ""From: mikel@test.lindsaar.net\r\nTo: you@...\@NL```\@NL### Making an email, have it your way:\@NL```ruby\@NLmail = Mail.new do\@NL  body File.read('body.txt')\@NLend\@NLmail['from'] = 'mikel@test.lindsaar.net'\@NLmail[:to]    = 'you@test.lindsaar.net'\@NLmail.subject = 'This is a test email'\@NLmail.header['X-Custom-Header'] = 'custom value'\@NLmail.to_s #=> ""From: mikel@test.lindsaar.net\r\nTo: you@...\@NL```\@NL### Don't Worry About Message IDs:\@NL```ruby\@NLmail = Mail.new do\@NL  to   'you@test.lindsaar.net'\@NL  body 'Some simple body'\@NLend\@NLmail.to_s =~ /Message\-ID: <[\d\w_]+@.+.mail/ #=> 27\@NL```\@NLMail will automatically add a Message-ID field if it is missing and\@NLgive it a unique, random Message-ID along the lines of:\@NL    <4a7ff76d7016_13a81ab802e1@local.host.mail>\@NL### Or do worry about Message-IDs:\@NL```ruby\@NLmail = Mail.new do\@NL  to         'you@test.lindsaar.net'\@NL  message_id '<ThisIsMyMessageId@some.domain.com>'\@NL  body       'Some simple body'\@NLend\@NLmail.to_s =~ /Message\-ID: <ThisIsMyMessageId@some.domain.com>/ #=> 27\@NL```\@NLMail will take the message_id you assign to it trusting that you know\@NLwhat you are doing.\@NL### Sending an email:\@NLMail defaults to sending via SMTP to local host port 25.  If you have a\@NLsendmail or postfix daemon running on this port, sending email is as\@NLeasy as:\@NL```ruby\@NLMail.deliver do\@NL  from     'me@test.lindsaar.net'\@NL  to       'you@test.lindsaar.net'\@NL  subject  'Here is the image you wanted'\@NL  body     File.read('body.txt')\@NL  add_file '/full/path/to/somefile.png'\@NLend\@NL```\@NLor\@NL```ruby\@NLmail = Mail.new do\@NL  from     'me@test.lindsaar.net'\@NL  to       'you@test.lindsaar.net'\@NL  subject  'Here is the image you wanted'\@NL  body     File.read('body.txt')\@NL  add_file :filename => 'somefile.png', :content => File.read('/somefile.png')\@NLend\@NLmail.deliver!\@NL```\@NLSending via sendmail can be done like so:\@NL```ruby\@NLmail = Mail.new do\@NL  from     'me@test.lindsaar.net'\@NL  to       'you@test.lindsaar.net'\@NL  subject  'Here is the image you wanted'\@NL  body     File.read('body.txt')\@NL  add_file :filename => 'somefile.png', :content => File.read('/somefile.png')\@NLend\@NLmail.delivery_method :sendmail\@NLmail.deliver\@NL```\@NLSending via smtp (for example to [mailcatcher](https://github.com/sj26/mailcatcher))\@NL```ruby\@NLMail.defaults do\@NL  delivery_method :smtp, address: ""localhost"", port: 1025\@NLend\@NL```\@NLExim requires its own delivery manager, and can be used like so:\@NL```ruby\@NLmail.delivery_method :exim, :location => ""/usr/bin/exim""\@NLmail.deliver\@NL```\@NLMail may be ""delivered"" to a logfile, too, for development and testing:\@NL```ruby\@NL# Delivers by logging the encoded message to $stdout\@NLmail.delivery_method :logger\@NL# Delivers to an existing logger at :debug severity\@NLmail.delivery_method :logger, logger: other_logger, severity: :debug\@NL```\@NL### Getting Emails from a POP Server:\@NLYou can configure Mail to receive email using <code>retriever_method</code>\@NLwithin <code>Mail.defaults</code>:\@NL```ruby\@NLMail.defaults do\@NL  retriever_method :pop3, :address    => ""pop.gmail.com"",\@NL                          :port       => 995,\@NL                          :user_name  => '<username>',\@NL                          :password   => '<password>',\@NL                          :enable_ssl => true\@NLend\@NL```\@NLYou can access incoming email in a number of ways.\@NLThe most recent email:\@NL```ruby\@NLMail.all    #=> Returns an array of all emails\@NLMail.first  #=> Returns the first unread email\@NLMail.last   #=> Returns the last unread email\@NL```\@NLThe first 10 emails sorted by date in ascending order:\@NL```ruby\@NLemails = Mail.find(:what => :first, :count => 10, :order => :asc)\@NLemails.length #=> 10\@NL```\@NLOr even all emails:\@NL```ruby\@NLemails = Mail.all\@NLemails.length #=> LOTS!\@NL```\@NL### Reading an Email\@NL```ruby\@NLmail = Mail.read('/path/to/message.eml')\@NLmail.envelope_from   #=> 'mikel@test.lindsaar.net'\@NLmail.from.addresses  #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']\@NLmail.sender.address  #=> 'mikel@test.lindsaar.net'\@NLmail.to              #=> 'bob@test.lindsaar.net'\@NLmail.cc              #=> 'sam@test.lindsaar.net'\@NLmail.subject         #=> ""This is the subject""\@NLmail.date.to_s       #=> '21 Nov 1997 09:55:06 -0600'\@NLmail.message_id      #=> '<4D6AA7EB.6490534@xxx.xxx>'\@NLmail.decoded         #=> 'This is the body of the email...\@NL```\@NLMany more methods available.\@NL### Reading a Multipart Email\@NL```ruby\@NLmail = Mail.read('multipart_email')\@NLmail.multipart?          #=> true\@NLmail.parts.length        #=> 2\@NLmail.body.preamble       #=> ""Text before the first part""\@NLmail.body.epilogue       #=> ""Text after the last part""\@NLmail.parts.map { |p| p.content_type }  #=> ['text/plain', 'application/pdf']\@NLmail.parts.map { |p| p.class }         #=> [Mail::Message, Mail::Message]\@NLmail.parts[0].content_type_parameters  #=> {'charset' => 'ISO-8859-1'}\@NLmail.parts[1].content_type_parameters  #=> {'name' => 'my.pdf'}\@NL```\@NLMail generates a tree of parts.  Each message has many or no parts.  Each part\@NLis another message which can have many or no parts.\@NLA message will only have parts if it is a multipart/mixed or multipart/related\@NLcontent type and has a boundary defined.\@NL### Testing and Extracting Attachments\@NL```ruby\@NLmail.attachments.each do | attachment |\@NL  # Attachments is an AttachmentsList object containing a\@NL  # number of Part objects\@NL  if (attachment.content_type.start_with?('image/'))\@NL    # extracting images for example...\@NL    filename = attachment.filename\@NL    begin\@NL      File.open(images_dir + filename, ""w+b"", 0644) {|f| f.write attachment.decoded}\@NL    rescue => e\@NL      puts ""Unable to save data for #{filename} because #{e.message}""\@NL    end\@NL  end\@NLend\@NL```\@NL### Writing and Sending a Multipart/Alternative (HTML and Text) Email\@NLMail makes some basic assumptions and makes doing the common thing as\@NLsimple as possible.... (asking a lot from a mail library)\@NL```ruby\@NLmail = Mail.deliver do\@NL  to      'nicolas@test.lindsaar.net.au'\@NL  from    'Mikel Lindsaar <mikel@test.lindsaar.net.au>'\@NL  subject 'First multipart email sent with Mail'\@NL  text_part do\@NL    body 'This is plain text'\@NL  end\@NL  html_part do\@NL    content_type 'text/html; charset=UTF-8'\@NL    body '<h1>This is HTML</h1>'\@NL  end\@NLend\@NL```\@NLMail then delivers the email at the end of the block and returns the\@NLresulting Mail::Message object, which you can then inspect if you\@NLso desire...\@NL```\@NLputs mail.to_s #=>\@NLTo: nicolas@test.lindsaar.net.au\@NLFrom: Mikel Lindsaar <mikel@test.lindsaar.net.au>\@NLSubject: First multipart email sent with Mail\@NLContent-Type: multipart/alternative;\@NL  boundary=--==_mimepart_4a914f0c911be_6f0f1ab8026659\@NLMessage-ID: <4a914f12ac7e_6f0f1ab80267d1@baci.local.mail>\@NLDate: Mon, 24 Aug 2009 00:15:46 +1000\@NLMime-Version: 1.0\@NLContent-Transfer-Encoding: 7bit\@NL----==_mimepart_4a914f0c911be_6f0f1ab8026659\@NLContent-ID: <4a914f12c8c4_6f0f1ab80268d6@baci.local.mail>\@NLDate: Mon, 24 Aug 2009 00:15:46 +1000\@NLMime-Version: 1.0\@NLContent-Type: text/plain\@NLContent-Transfer-Encoding: 7bit\@NLThis is plain text\@NL----==_mimepart_4a914f0c911be_6f0f1ab8026659\@NLContent-Type: text/html; charset=UTF-8\@NLContent-ID: <4a914f12cf86_6f0f1ab802692c@baci.local.mail>\@NLDate: Mon, 24 Aug 2009 00:15:46 +1000\@NLMime-Version: 1.0\@NLContent-Transfer-Encoding: 7bit\@NL<h1>This is HTML</h1>\@NL----==_mimepart_4a914f0c911be_6f0f1ab8026659--\@NL```\@NLMail inserts the content transfer encoding, the mime version,\@NLthe content-id's and handles the content-type and boundary.\@NLMail assumes that if your text in the body is only us-ascii, that your\@NLtransfer encoding is 7bit and it is text/plain.  You can override this\@NLby explicitly declaring it.\@NL### Making Multipart/Alternate, Without a Block\@NLYou don't have to use a block with the text and html part included, you\@NLcan just do it declaratively.  However, you need to add Mail::Parts to\@NLan email, not Mail::Messages.\@NL```ruby\@NLmail = Mail.new do\@NL  to      'nicolas@test.lindsaar.net.au'\@NL  from    'Mikel Lindsaar <mikel@test.lindsaar.net.au>'\@NL  subject 'First multipart email sent with Mail'\@NLend\@NLtext_part = Mail::Part.new do\@NL  body 'This is plain text'\@NLend\@NLhtml_part = Mail::Part.new do\@NL  content_type 'text/html; charset=UTF-8'\@NL  body '<h1>This is HTML</h1>'\@NLend\@NLmail.text_part = text_part\@NLmail.html_part = html_part\@NL```\@NLResults in the same email as done using the block form\@NL### Getting Error Reports from an Email:\@NL```ruby\@NL@mail = Mail.read('/path/to/bounce_message.eml')\@NL@mail.bounced?         #=> true\@NL@mail.final_recipient  #=> rfc822;mikel@dont.exist.com\@NL@mail.action           #=> failed\@NL@mail.error_status     #=> 5.5.0\@NL@mail.diagnostic_code  #=> smtp;550 Requested action not taken: mailbox unavailable\@NL@mail.retryable?       #=> false\@NL```\@NL### Attaching and Detaching Files\@NLYou can just read the file off an absolute path, Mail will try\@NLto guess the mime_type and will encode the file in Base64 for you.\@NL```ruby\@NL@mail = Mail.new\@NL@mail.add_file(""/path/to/file.jpg"")\@NL@mail.parts.first.attachment? #=> true\@NL@mail.parts.first.content_transfer_encoding.to_s #=> 'base64'\@NL@mail.attachments.first.mime_type #=> 'image/jpg'\@NL@mail.attachments.first.filename #=> 'file.jpg'\@NL@mail.attachments.first.decoded == File.read('/path/to/file.jpg') #=> true\@NL```\@NLOr You can pass in file_data and give it a filename, again, mail\@NLwill try and guess the mime_type for you.\@NL```ruby\@NL@mail = Mail.new\@NL@mail.attachments['myfile.pdf'] = File.read('path/to/myfile.pdf')\@NL@mail.parts.first.attachment? #=> true\@NL@mail.attachments.first.mime_type #=> 'application/pdf'\@NL@mail.attachments.first.decoded == File.read('path/to/myfile.pdf') #=> true\@NL```\@NLYou can also override the guessed MIME media type if you really know better\@NLthan mail (this should be rarely needed)\@NL```ruby\@NL@mail = Mail.new\@NL@mail.attachments['myfile.pdf'] = { :mime_type => 'application/x-pdf',\@NL                                    :content => File.read('path/to/myfile.pdf') }\@NL@mail.parts.first.mime_type #=> 'application/x-pdf'\@NL```\@NLOf course... Mail will round trip an attachment as well\@NL```ruby\@NL@mail = Mail.new do\@NL  to      'nicolas@test.lindsaar.net.au'\@NL  from    'Mikel Lindsaar <mikel@test.lindsaar.net.au>'\@NL  subject 'First multipart email sent with Mail'\@NL  text_part do\@NL    body 'Here is the attachment you wanted'\@NL  end\@NL  html_part do\@NL    content_type 'text/html; charset=UTF-8'\@NL    body '<h1>Funky Title</h1><p>Here is the attachment you wanted</p>'\@NL  end\@NL  add_file '/path/to/myfile.pdf'\@NLend\@NL@round_tripped_mail = Mail.new(@mail.encoded)\@NL@round_tripped_mail.attachments.length #=> 1\@NL@round_tripped_mail.attachments.first.filename #=> 'myfile.pdf'\@NL```\@NLSee ""Testing and extracting attachments"" above for more details.\@NL## Using Mail with Testing or Spec'ing Libraries\@NLIf mail is part of your system, you'll need a way to test it without actually\@NLsending emails, the TestMailer can do this for you.\@NL```ruby\@NLrequire 'mail'\@NL=> true\@NLMail.defaults do\@NL  delivery_method :test\@NLend\@NL=> #<Mail::Configuration:0x19345a8 @delivery_method=Mail::TestMailer>\@NLMail::TestMailer.deliveries\@NL=> []\@NLMail.deliver do\@NL  to 'mikel@me.com'\@NL  from 'you@you.com'\@NL  subject 'testing'\@NL  body 'hello'\@NLend\@NL=> #<Mail::Message:0x19284ec ...\@NLMail::TestMailer.deliveries.length\@NL=> 1\@NLMail::TestMailer.deliveries.first\@NL=> #<Mail::Message:0x19284ec ...\@NLMail::TestMailer.deliveries.clear\@NL=> []\@NL```\@NLThere is also a set of RSpec matchers stolen/inspired by Shoulda's ActionMailer matchers (you'll want to set <code>delivery_method</code> as above too):\@NL```ruby\@NLMail.defaults do\@NL  delivery_method :test # in practice you'd do this in spec_helper.rb\@NLend\@NLdescribe ""sending an email"" do\@NL  include Mail::Matchers\@NL  before(:each) do\@NL    Mail::TestMailer.deliveries.clear\@NL    Mail.deliver do\@NL      to ['mikel@me.com', 'mike2@me.com']\@NL      from 'you@you.com'\@NL      subject 'testing'\@NL      body 'hello'\@NL    end\@NL  end\@NL  it { is_expected.to have_sent_email } # passes if any email at all was sent\@NL  it { is_expected.to have_sent_email.from('you@you.com') }\@NL  it { is_expected.to have_sent_email.to('mike1@me.com') }\@NL  # can specify a list of recipients...\@NL  it { is_expected.to have_sent_email.to(['mike1@me.com', 'mike2@me.com']) }\@NL  # ...or chain recipients together\@NL  it { is_expected.to have_sent_email.to('mike1@me.com').to('mike2@me.com') }\@NL  it { is_expected.to have_sent_email.with_subject('testing') }\@NL  it { is_expected.to have_sent_email.with_body('hello') }\@NL  # Can match subject or body with a regex\@NL  # (or anything that responds_to? :match)\@NL  it { is_expected.to have_sent_email.matching_subject(/test(ing)?/) }\@NL  it { is_expected.to have_sent_email.matching_body(/h(a|e)llo/) }\@NL  # Can chain together modifiers\@NL  # Note that apart from recipients, repeating a modifier overwrites old value.\@NL  it { is_expected.to have_sent_email.from('you@you.com').to('mike1@me.com').matching_body(/hell/)\@NL  # test for attachments\@NL  # ... by specific attachment\@NL  it { is_expected.to have_sent_email.with_attachments(my_attachment) }\@NL  # ... or any attachment\@NL  it { is_expected.to have_sent_email.with_attachments(any_attachment) }\@NL  # ... by array of attachments\@NL  it { is_expected.to have_sent_email.with_attachments([my_attachment1, my_attachment2]) } #note that order is important\@NL  #... by presence\@NL  it { is_expected.to have_sent_email.with_any_attachments }\@NL  #... or by absence\@NL  it { is_expected.to have_sent_email.with_no_attachments }\@NLend\@NL```\@NL## Excerpts from TREC Spam Corpus 2005\@NLThe spec fixture files in spec/fixtures/emails/from_trec_2005 are from the\@NL2005 TREC Public Spam Corpus. They remain copyrighted under the terms of\@NLthat project and license agreement. They are used in this project to verify\@NLand describe the development of this email parser implementation.\@NLhttp://plg.uwaterloo.ca/~gvcormac/treccorpus/\@NLThey are used as allowed by 'Permitted Uses, Clause 3':\@NL    ""Small excerpts of the information may be displayed to others\@NL     or published in a scientific or technical context, solely for\@NL     the purpose of describing the research and development and\@NL     related issues.""\@NL     -- http://plg.uwaterloo.ca/~gvcormac/treccorpus/\@NL## License\@NL(The MIT License)\@NLCopyright (c) 2009-2016 Mikel Lindsaar\@NLPermission is hereby granted, free of charge, to any person obtaining\@NLa copy of this software and associated documentation files (the\@NL'Software'), to deal in the Software without restriction, including\@NLwithout limitation the rights to use, copy, modify, merge, publish,\@NLdistribute, sublicense, and/or sell copies of the Software, and to\@NLpermit persons to whom the Software is furnished to do so, subject to\@NLthe following conditions:\@NLThe above copyright notice and this permission notice shall be\@NLincluded in all copies or substantial portions of the Software.\@NLTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\@NLEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\@NLMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\@NLIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\@NLCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\@NLTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\@NLSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
Severity: Minor
Found in licenses.csv by fixme

TODO found
Open

gem "recaptcha", '< 3', require: "recaptcha/rails" # TODO: Update
Severity: Minor
Found in Gemfile by fixme

TODO found
Open

            tracker("Agent: #{current_user.name}", "Closed", @topic.to_param) #TODO: Need minutes

TODO found
Open

        # TODO THIS IS A HACK because there appears to be no difference in language files for chinese simple and traditional
Severity: Minor
Found in app/helpers/admin_helper.rb by fixme

HACK found
Open

        # TODO THIS IS A HACK because there appears to be no difference in language files for chinese simple and traditional
Severity: Minor
Found in app/helpers/admin_helper.rb by fixme

TODO found
Open

        # TODO probably can refactor this

TODO found
Open

            tracker("Agent: #{agent.name}", "User Replied", @topic.to_param) #TODO: Need minutes
Severity: Minor
Found in app/controllers/posts_controller.rb by fixme

TODO found
Open

mail,2.7.1,MIT,https://github.com/mikel/mail,"Copyright (c) 2009-2016 Mikel Lindsaar\@NLPermission is hereby granted, free of charge, to any person obtaining\@NLa copy of this software and associated documentation files (the\@NL'Software'), to deal in the Software without restriction, including\@NLwithout limitation the rights to use, copy, modify, merge, publish,\@NLdistribute, sublicense, and/or sell copies of the Software, and to\@NLpermit persons to whom the Software is furnished to do so, subject to\@NLthe following conditions:\@NLThe above copyright notice and this permission notice shall be\@NLincluded in all copies or substantial portions of the Software.\@NLTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\@NLEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\@NLMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\@NLIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\@NLCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\@NLTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\@NLSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\@NL# Mail [![Build Status](https://travis-ci.org/mikel/mail.png?branch=master)](https://travis-ci.org/mikel/mail)\@NL## Introduction\@NLMail is an internet library for Ruby that is designed to handle emails\@NLgeneration, parsing and sending in a simple, rubyesque manner.\@NLThe purpose of this library is to provide a single point of access to handle\@NLall email functions, including sending and receiving emails.  All network\@NLtype actions are done through proxy methods to Net::SMTP, Net::POP3 etc.\@NLBuilt from my experience with TMail, it is designed to be a pure ruby\@NLimplementation that makes generating, sending and parsing emails a no\@NLbrainer.\@NLIt is also designed from the ground up to work with the more modern versions\@NLof Ruby.  This is because Ruby > 1.9 handles text encodings much more wonderfully\@NLthan Ruby 1.8.x and so these features have been taken full advantage of in this\@NLlibrary allowing Mail to handle a lot more messages more cleanly than TMail.\@NLMail does run on Ruby 1.8.x... it's just not as fun to code.\@NLFinally, Mail has been designed with a very simple object oriented system\@NLthat really opens up the email messages you are parsing, if you know what\@NLyou are doing, you can fiddle with every last bit of your email directly.\@NL## Donations\@NLMail has been downloaded millions of times, by people around the world, in fact,\@NLit represents more than 1% of *all* gems downloaded.\@NLIt is (like all open source software) a labour of love and something I am doing\@NLwith my own free time.  If you would like to say thanks, please feel free to\@NL[make a donation](http://www.pledgie.com/campaigns/8790) and feel free to send\@NLme a nice email :)\@NL<a href='http://www.pledgie.com/campaigns/8790'><img alt='Click here to lend your support to: mail and make a donation at www.pledgie.com !' src='http://www.pledgie.com/campaigns/8790.png?skin_name=chrome' border='0' /></a>\@NL# Contents\@NL* [Compatibility](#compatibility)\@NL* [Discussion](#discussion)\@NL* [Current Capabilities of Mail](#current-capabilities-of-mail)\@NL* [Roadmap](#roadmap)\@NL* [Testing Policy](#testing-policy)\@NL* [API Policy](#api-policy)\@NL* [Installation](#installation)\@NL* [Encodings](#encodings)\@NL* [Contributing](#contributing)\@NL* [Usage](#usage)\@NL* [Core Extensions](#core-extensions)\@NL* [Excerpts from TREC Span Corpus 2005](#excerpts-from-trec-span-corpus-2005)\@NL* [License](#license)\@NL## Compatibility\@NLMail supports Ruby 1.8.7+, including JRuby and Rubinius.\@NLEvery Mail commit is tested by Travis on [all supported Ruby versions](https://github.com/mikel/mail/blob/master/.travis.yml).\@NL## Discussion\@NLIf you want to discuss mail with like minded individuals, please subscribe to\@NLthe [Google Group](http://groups.google.com/group/mail-ruby).\@NL## Current Capabilities of Mail\@NL* RFC5322 Support, Reading and Writing\@NL* RFC6532 Support, reading UTF-8 headers\@NL* RFC2045-2049 Support for multipart emails\@NL* Support for creating multipart alternate emails\@NL* Support for reading multipart/report emails &amp; getting details from such\@NL* Wrappers for File, Net/POP3, Net/SMTP\@NL* Auto-encoding of non-US-ASCII bodies and header fields\@NLMail is RFC5322 and RFC6532 compliant now, that is, it can parse US-ASCII and UTF-8\@NLemails and generate US-ASCII emails. There are a few obsoleted syntax emails that\@NLit will have problems with, but it also is quite robust, meaning, if it finds something\@NLit doesn't understand it will not crash, instead, it will skip the problem and keep\@NLparsing. In the case of a header it doesn't understand, it will initialise the header\@NLas an optional unstructured field and continue parsing.\@NLThis means Mail won't (ever) crunch your data (I think).\@NLYou can also create MIME emails.  There are helper methods for making a\@NLmultipart/alternate email for text/plain and text/html (the most common pair)\@NLand you can manually create any other type of MIME email.\@NL## Roadmap\@NLNext TODO:\@NL* Improve MIME support for character sets in headers, currently works, mostly, needs\@NL  refinement.\@NL## Testing Policy\@NLBasically... we do BDD on Mail.  No method gets written in Mail without a\@NLcorresponding or covering spec.  We expect as a minimum 100% coverage\@NLmeasured by RCov.  While this is not perfect by any measure, it is pretty\@NLgood.  Additionally, all functional tests from TMail are to be passing before\@NLthe gem gets released.\@NLIt also means you can be sure Mail will behave correctly.\@NLNote: If you care about core extensions (aka ""monkey-patching""), please read the Core Extensions section near the end of this README.\@NL## API Policy\@NLNo API removals within a single point release.  All removals to be deprecated with\@NLwarnings for at least one MINOR point release before removal.\@NLAlso, all private or protected methods to be declared as such - though this is still I/P.\@NL## Installation\@NLInstallation is fairly simple, I host mail on rubygems, so you can just do:\@NL    # gem install mail\@NL## Encodings\@NLIf you didn't know, handling encodings in Emails is not as straight forward as you\@NLwould hope.\@NLI have tried to simplify it some:\@NL1. All objects that can render into an email, have an `#encoded` method.  Encoded will\@NL   return the object as a complete string ready to send in the mail system, that is,\@NL   it will include the header field and value and CRLF at the end and wrapped as\@NL   needed.\@NL2. All objects that can render into an email, have a `#decoded` method.  Decoded will\@NL   return the object's ""value"" only as a string.  This means it will not include\@NL   the header fields (like 'To:' or 'Subject:').\@NL3. By default, calling <code>#to_s</code> on a container object will call its encoded\@NL   method, while <code>#to_s</code> on a field object will call its decoded method.\@NL   So calling <code>#to_s</code> on a Mail object will return the mail, all encoded\@NL   ready to send, while calling <code>#to_s</code> on the From field or the body will\@NL   return the decoded value of the object. The header object of Mail is considered a\@NL   container. If you are in doubt, call <code>#encoded</code>, or <code>#decoded</code>\@NL   explicitly, this is safer if you are not sure.\@NL4. Structured fields that have parameter values that can be encoded (e.g. Content-Type) will\@NL   provide decoded parameter values when you call the parameter names as methods against\@NL   the object.\@NL5. Structured fields that have parameter values that can be encoded (e.g. Content-Type) will\@NL   provide encoded parameter values when you call the parameter names through the\@NL   <code>object.parameters['<parameter_name>']</code> method call.\@NL## Contributing\@NLPlease do!  Contributing is easy in Mail.  Please read the CONTRIBUTING.md document for more info\@NL## Usage\@NLAll major mail functions should be able to happen from the Mail module.\@NLSo, you should be able to just <code>require 'mail'</code> to get started.\@NL### Making an email\@NL```ruby\@NLmail = Mail.new do\@NL  from    'mikel@test.lindsaar.net'\@NL  to      'you@test.lindsaar.net'\@NL  subject 'This is a test email'\@NL  body    File.read('body.txt')\@NLend\@NLmail.to_s #=> ""From: mikel@test.lindsaar.net\r\nTo: you@...\@NL```\@NL### Making an email, have it your way:\@NL```ruby\@NLmail = Mail.new do\@NL  body File.read('body.txt')\@NLend\@NLmail['from'] = 'mikel@test.lindsaar.net'\@NLmail[:to]    = 'you@test.lindsaar.net'\@NLmail.subject = 'This is a test email'\@NLmail.header['X-Custom-Header'] = 'custom value'\@NLmail.to_s #=> ""From: mikel@test.lindsaar.net\r\nTo: you@...\@NL```\@NL### Don't Worry About Message IDs:\@NL```ruby\@NLmail = Mail.new do\@NL  to   'you@test.lindsaar.net'\@NL  body 'Some simple body'\@NLend\@NLmail.to_s =~ /Message\-ID: <[\d\w_]+@.+.mail/ #=> 27\@NL```\@NLMail will automatically add a Message-ID field if it is missing and\@NLgive it a unique, random Message-ID along the lines of:\@NL    <4a7ff76d7016_13a81ab802e1@local.host.mail>\@NL### Or do worry about Message-IDs:\@NL```ruby\@NLmail = Mail.new do\@NL  to         'you@test.lindsaar.net'\@NL  message_id '<ThisIsMyMessageId@some.domain.com>'\@NL  body       'Some simple body'\@NLend\@NLmail.to_s =~ /Message\-ID: <ThisIsMyMessageId@some.domain.com>/ #=> 27\@NL```\@NLMail will take the message_id you assign to it trusting that you know\@NLwhat you are doing.\@NL### Sending an email:\@NLMail defaults to sending via SMTP to local host port 25.  If you have a\@NLsendmail or postfix daemon running on this port, sending email is as\@NLeasy as:\@NL```ruby\@NLMail.deliver do\@NL  from     'me@test.lindsaar.net'\@NL  to       'you@test.lindsaar.net'\@NL  subject  'Here is the image you wanted'\@NL  body     File.read('body.txt')\@NL  add_file '/full/path/to/somefile.png'\@NLend\@NL```\@NLor\@NL```ruby\@NLmail = Mail.new do\@NL  from     'me@test.lindsaar.net'\@NL  to       'you@test.lindsaar.net'\@NL  subject  'Here is the image you wanted'\@NL  body     File.read('body.txt')\@NL  add_file :filename => 'somefile.png', :content => File.read('/somefile.png')\@NLend\@NLmail.deliver!\@NL```\@NLSending via sendmail can be done like so:\@NL```ruby\@NLmail = Mail.new do\@NL  from     'me@test.lindsaar.net'\@NL  to       'you@test.lindsaar.net'\@NL  subject  'Here is the image you wanted'\@NL  body     File.read('body.txt')\@NL  add_file :filename => 'somefile.png', :content => File.read('/somefile.png')\@NLend\@NLmail.delivery_method :sendmail\@NLmail.deliver\@NL```\@NLSending via smtp (for example to [mailcatcher](https://github.com/sj26/mailcatcher))\@NL```ruby\@NLMail.defaults do\@NL  delivery_method :smtp, address: ""localhost"", port: 1025\@NLend\@NL```\@NLExim requires its own delivery manager, and can be used like so:\@NL```ruby\@NLmail.delivery_method :exim, :location => ""/usr/bin/exim""\@NLmail.deliver\@NL```\@NLMail may be ""delivered"" to a logfile, too, for development and testing:\@NL```ruby\@NL# Delivers by logging the encoded message to $stdout\@NLmail.delivery_method :logger\@NL# Delivers to an existing logger at :debug severity\@NLmail.delivery_method :logger, logger: other_logger, severity: :debug\@NL```\@NL### Getting Emails from a POP Server:\@NLYou can configure Mail to receive email using <code>retriever_method</code>\@NLwithin <code>Mail.defaults</code>:\@NL```ruby\@NLMail.defaults do\@NL  retriever_method :pop3, :address    => ""pop.gmail.com"",\@NL                          :port       => 995,\@NL                          :user_name  => '<username>',\@NL                          :password   => '<password>',\@NL                          :enable_ssl => true\@NLend\@NL```\@NLYou can access incoming email in a number of ways.\@NLThe most recent email:\@NL```ruby\@NLMail.all    #=> Returns an array of all emails\@NLMail.first  #=> Returns the first unread email\@NLMail.last   #=> Returns the last unread email\@NL```\@NLThe first 10 emails sorted by date in ascending order:\@NL```ruby\@NLemails = Mail.find(:what => :first, :count => 10, :order => :asc)\@NLemails.length #=> 10\@NL```\@NLOr even all emails:\@NL```ruby\@NLemails = Mail.all\@NLemails.length #=> LOTS!\@NL```\@NL### Reading an Email\@NL```ruby\@NLmail = Mail.read('/path/to/message.eml')\@NLmail.envelope_from   #=> 'mikel@test.lindsaar.net'\@NLmail.from.addresses  #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']\@NLmail.sender.address  #=> 'mikel@test.lindsaar.net'\@NLmail.to              #=> 'bob@test.lindsaar.net'\@NLmail.cc              #=> 'sam@test.lindsaar.net'\@NLmail.subject         #=> ""This is the subject""\@NLmail.date.to_s       #=> '21 Nov 1997 09:55:06 -0600'\@NLmail.message_id      #=> '<4D6AA7EB.6490534@xxx.xxx>'\@NLmail.decoded         #=> 'This is the body of the email...\@NL```\@NLMany more methods available.\@NL### Reading a Multipart Email\@NL```ruby\@NLmail = Mail.read('multipart_email')\@NLmail.multipart?          #=> true\@NLmail.parts.length        #=> 2\@NLmail.body.preamble       #=> ""Text before the first part""\@NLmail.body.epilogue       #=> ""Text after the last part""\@NLmail.parts.map { |p| p.content_type }  #=> ['text/plain', 'application/pdf']\@NLmail.parts.map { |p| p.class }         #=> [Mail::Message, Mail::Message]\@NLmail.parts[0].content_type_parameters  #=> {'charset' => 'ISO-8859-1'}\@NLmail.parts[1].content_type_parameters  #=> {'name' => 'my.pdf'}\@NL```\@NLMail generates a tree of parts.  Each message has many or no parts.  Each part\@NLis another message which can have many or no parts.\@NLA message will only have parts if it is a multipart/mixed or multipart/related\@NLcontent type and has a boundary defined.\@NL### Testing and Extracting Attachments\@NL```ruby\@NLmail.attachments.each do | attachment |\@NL  # Attachments is an AttachmentsList object containing a\@NL  # number of Part objects\@NL  if (attachment.content_type.start_with?('image/'))\@NL    # extracting images for example...\@NL    filename = attachment.filename\@NL    begin\@NL      File.open(images_dir + filename, ""w+b"", 0644) {|f| f.write attachment.decoded}\@NL    rescue => e\@NL      puts ""Unable to save data for #{filename} because #{e.message}""\@NL    end\@NL  end\@NLend\@NL```\@NL### Writing and Sending a Multipart/Alternative (HTML and Text) Email\@NLMail makes some basic assumptions and makes doing the common thing as\@NLsimple as possible.... (asking a lot from a mail library)\@NL```ruby\@NLmail = Mail.deliver do\@NL  to      'nicolas@test.lindsaar.net.au'\@NL  from    'Mikel Lindsaar <mikel@test.lindsaar.net.au>'\@NL  subject 'First multipart email sent with Mail'\@NL  text_part do\@NL    body 'This is plain text'\@NL  end\@NL  html_part do\@NL    content_type 'text/html; charset=UTF-8'\@NL    body '<h1>This is HTML</h1>'\@NL  end\@NLend\@NL```\@NLMail then delivers the email at the end of the block and returns the\@NLresulting Mail::Message object, which you can then inspect if you\@NLso desire...\@NL```\@NLputs mail.to_s #=>\@NLTo: nicolas@test.lindsaar.net.au\@NLFrom: Mikel Lindsaar <mikel@test.lindsaar.net.au>\@NLSubject: First multipart email sent with Mail\@NLContent-Type: multipart/alternative;\@NL  boundary=--==_mimepart_4a914f0c911be_6f0f1ab8026659\@NLMessage-ID: <4a914f12ac7e_6f0f1ab80267d1@baci.local.mail>\@NLDate: Mon, 24 Aug 2009 00:15:46 +1000\@NLMime-Version: 1.0\@NLContent-Transfer-Encoding: 7bit\@NL----==_mimepart_4a914f0c911be_6f0f1ab8026659\@NLContent-ID: <4a914f12c8c4_6f0f1ab80268d6@baci.local.mail>\@NLDate: Mon, 24 Aug 2009 00:15:46 +1000\@NLMime-Version: 1.0\@NLContent-Type: text/plain\@NLContent-Transfer-Encoding: 7bit\@NLThis is plain text\@NL----==_mimepart_4a914f0c911be_6f0f1ab8026659\@NLContent-Type: text/html; charset=UTF-8\@NLContent-ID: <4a914f12cf86_6f0f1ab802692c@baci.local.mail>\@NLDate: Mon, 24 Aug 2009 00:15:46 +1000\@NLMime-Version: 1.0\@NLContent-Transfer-Encoding: 7bit\@NL<h1>This is HTML</h1>\@NL----==_mimepart_4a914f0c911be_6f0f1ab8026659--\@NL```\@NLMail inserts the content transfer encoding, the mime version,\@NLthe content-id's and handles the content-type and boundary.\@NLMail assumes that if your text in the body is only us-ascii, that your\@NLtransfer encoding is 7bit and it is text/plain.  You can override this\@NLby explicitly declaring it.\@NL### Making Multipart/Alternate, Without a Block\@NLYou don't have to use a block with the text and html part included, you\@NLcan just do it declaratively.  However, you need to add Mail::Parts to\@NLan email, not Mail::Messages.\@NL```ruby\@NLmail = Mail.new do\@NL  to      'nicolas@test.lindsaar.net.au'\@NL  from    'Mikel Lindsaar <mikel@test.lindsaar.net.au>'\@NL  subject 'First multipart email sent with Mail'\@NLend\@NLtext_part = Mail::Part.new do\@NL  body 'This is plain text'\@NLend\@NLhtml_part = Mail::Part.new do\@NL  content_type 'text/html; charset=UTF-8'\@NL  body '<h1>This is HTML</h1>'\@NLend\@NLmail.text_part = text_part\@NLmail.html_part = html_part\@NL```\@NLResults in the same email as done using the block form\@NL### Getting Error Reports from an Email:\@NL```ruby\@NL@mail = Mail.read('/path/to/bounce_message.eml')\@NL@mail.bounced?         #=> true\@NL@mail.final_recipient  #=> rfc822;mikel@dont.exist.com\@NL@mail.action           #=> failed\@NL@mail.error_status     #=> 5.5.0\@NL@mail.diagnostic_code  #=> smtp;550 Requested action not taken: mailbox unavailable\@NL@mail.retryable?       #=> false\@NL```\@NL### Attaching and Detaching Files\@NLYou can just read the file off an absolute path, Mail will try\@NLto guess the mime_type and will encode the file in Base64 for you.\@NL```ruby\@NL@mail = Mail.new\@NL@mail.add_file(""/path/to/file.jpg"")\@NL@mail.parts.first.attachment? #=> true\@NL@mail.parts.first.content_transfer_encoding.to_s #=> 'base64'\@NL@mail.attachments.first.mime_type #=> 'image/jpg'\@NL@mail.attachments.first.filename #=> 'file.jpg'\@NL@mail.attachments.first.decoded == File.read('/path/to/file.jpg') #=> true\@NL```\@NLOr You can pass in file_data and give it a filename, again, mail\@NLwill try and guess the mime_type for you.\@NL```ruby\@NL@mail = Mail.new\@NL@mail.attachments['myfile.pdf'] = File.read('path/to/myfile.pdf')\@NL@mail.parts.first.attachment? #=> true\@NL@mail.attachments.first.mime_type #=> 'application/pdf'\@NL@mail.attachments.first.decoded == File.read('path/to/myfile.pdf') #=> true\@NL```\@NLYou can also override the guessed MIME media type if you really know better\@NLthan mail (this should be rarely needed)\@NL```ruby\@NL@mail = Mail.new\@NL@mail.attachments['myfile.pdf'] = { :mime_type => 'application/x-pdf',\@NL                                    :content => File.read('path/to/myfile.pdf') }\@NL@mail.parts.first.mime_type #=> 'application/x-pdf'\@NL```\@NLOf course... Mail will round trip an attachment as well\@NL```ruby\@NL@mail = Mail.new do\@NL  to      'nicolas@test.lindsaar.net.au'\@NL  from    'Mikel Lindsaar <mikel@test.lindsaar.net.au>'\@NL  subject 'First multipart email sent with Mail'\@NL  text_part do\@NL    body 'Here is the attachment you wanted'\@NL  end\@NL  html_part do\@NL    content_type 'text/html; charset=UTF-8'\@NL    body '<h1>Funky Title</h1><p>Here is the attachment you wanted</p>'\@NL  end\@NL  add_file '/path/to/myfile.pdf'\@NLend\@NL@round_tripped_mail = Mail.new(@mail.encoded)\@NL@round_tripped_mail.attachments.length #=> 1\@NL@round_tripped_mail.attachments.first.filename #=> 'myfile.pdf'\@NL```\@NLSee ""Testing and extracting attachments"" above for more details.\@NL## Using Mail with Testing or Spec'ing Libraries\@NLIf mail is part of your system, you'll need a way to test it without actually\@NLsending emails, the TestMailer can do this for you.\@NL```ruby\@NLrequire 'mail'\@NL=> true\@NLMail.defaults do\@NL  delivery_method :test\@NLend\@NL=> #<Mail::Configuration:0x19345a8 @delivery_method=Mail::TestMailer>\@NLMail::TestMailer.deliveries\@NL=> []\@NLMail.deliver do\@NL  to 'mikel@me.com'\@NL  from 'you@you.com'\@NL  subject 'testing'\@NL  body 'hello'\@NLend\@NL=> #<Mail::Message:0x19284ec ...\@NLMail::TestMailer.deliveries.length\@NL=> 1\@NLMail::TestMailer.deliveries.first\@NL=> #<Mail::Message:0x19284ec ...\@NLMail::TestMailer.deliveries.clear\@NL=> []\@NL```\@NLThere is also a set of RSpec matchers stolen/inspired by Shoulda's ActionMailer matchers (you'll want to set <code>delivery_method</code> as above too):\@NL```ruby\@NLMail.defaults do\@NL  delivery_method :test # in practice you'd do this in spec_helper.rb\@NLend\@NLdescribe ""sending an email"" do\@NL  include Mail::Matchers\@NL  before(:each) do\@NL    Mail::TestMailer.deliveries.clear\@NL    Mail.deliver do\@NL      to ['mikel@me.com', 'mike2@me.com']\@NL      from 'you@you.com'\@NL      subject 'testing'\@NL      body 'hello'\@NL    end\@NL  end\@NL  it { is_expected.to have_sent_email } # passes if any email at all was sent\@NL  it { is_expected.to have_sent_email.from('you@you.com') }\@NL  it { is_expected.to have_sent_email.to('mike1@me.com') }\@NL  # can specify a list of recipients...\@NL  it { is_expected.to have_sent_email.to(['mike1@me.com', 'mike2@me.com']) }\@NL  # ...or chain recipients together\@NL  it { is_expected.to have_sent_email.to('mike1@me.com').to('mike2@me.com') }\@NL  it { is_expected.to have_sent_email.with_subject('testing') }\@NL  it { is_expected.to have_sent_email.with_body('hello') }\@NL  # Can match subject or body with a regex\@NL  # (or anything that responds_to? :match)\@NL  it { is_expected.to have_sent_email.matching_subject(/test(ing)?/) }\@NL  it { is_expected.to have_sent_email.matching_body(/h(a|e)llo/) }\@NL  # Can chain together modifiers\@NL  # Note that apart from recipients, repeating a modifier overwrites old value.\@NL  it { is_expected.to have_sent_email.from('you@you.com').to('mike1@me.com').matching_body(/hell/)\@NL  # test for attachments\@NL  # ... by specific attachment\@NL  it { is_expected.to have_sent_email.with_attachments(my_attachment) }\@NL  # ... or any attachment\@NL  it { is_expected.to have_sent_email.with_attachments(any_attachment) }\@NL  # ... by array of attachments\@NL  it { is_expected.to have_sent_email.with_attachments([my_attachment1, my_attachment2]) } #note that order is important\@NL  #... by presence\@NL  it { is_expected.to have_sent_email.with_any_attachments }\@NL  #... or by absence\@NL  it { is_expected.to have_sent_email.with_no_attachments }\@NLend\@NL```\@NL## Excerpts from TREC Spam Corpus 2005\@NLThe spec fixture files in spec/fixtures/emails/from_trec_2005 are from the\@NL2005 TREC Public Spam Corpus. They remain copyrighted under the terms of\@NLthat project and license agreement. They are used in this project to verify\@NLand describe the development of this email parser implementation.\@NLhttp://plg.uwaterloo.ca/~gvcormac/treccorpus/\@NLThey are used as allowed by 'Permitted Uses, Clause 3':\@NL    ""Small excerpts of the information may be displayed to others\@NL     or published in a scientific or technical context, solely for\@NL     the purpose of describing the research and development and\@NL     related issues.""\@NL     -- http://plg.uwaterloo.ca/~gvcormac/treccorpus/\@NL## License\@NL(The MIT License)\@NLCopyright (c) 2009-2016 Mikel Lindsaar\@NLPermission is hereby granted, free of charge, to any person obtaining\@NLa copy of this software and associated documentation files (the\@NL'Software'), to deal in the Software without restriction, including\@NLwithout limitation the rights to use, copy, modify, merge, publish,\@NLdistribute, sublicense, and/or sell copies of the Software, and to\@NLpermit persons to whom the Software is furnished to do so, subject to\@NLthe following conditions:\@NLThe above copyright notice and this permission notice shall be\@NLincluded in all copies or substantial portions of the Software.\@NLTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\@NLEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\@NLMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\@NLIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\@NLCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\@NLTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\@NLSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",/Users/scott/.rvm/gems/ruby-2.4.6/gems/mail-2.7.1
Severity: Minor
Found in license_report.csv by fixme

TODO found
Open

// TODO: Replace as necessary with SCSS equivalents

TODO found
Open

        # TODO probably can refactor this

TODO found
Open

# TODO: Resolve the following RuboCop violations
Severity: Minor
Found in .rubocop.yml by fixme

TODO found
Open

// TODO: replace this hack with a better direct link or modal slide over
Severity: Minor
Found in app/views/admin/users/show.js.erb by fixme
Severity
Category
Status
Source
Language