“...I've been working since 2008 with Ruby / Ruby on Rails, love a bit of Elixir / Phoenix and learning Rust. I also poke through other people's code and make PRs for OpenSource Ruby projects that sometimes make it. Currently working for InPay...”

Rob Lacey (contact@robl.me)
Senior Software Engineer, Brighton, UK

TMail and spam filtering

I’ve been musing over the past day or so on how best to assess whether our mailers are sending out messages that are likely to get caught by over zealous spam filters and render our e-mail campaigns useless.

One possible is to run all outbound e-mails through spam assassin, so for standard mailers we can just add a spec to check the content and for form mailers we can use it during validation before the final send off.

class TMail::Mail

  def spam?
    spam_filtered_body = %x[ echo '#{self.encoded}' | /usr/bin/spamassassin ]
    return !! spam_filtered_body.match(/X-Spam-Status:\sYes/)
  end

end