title: "smtp; 550 Messages should have one or no Reply-To headers, not 2" on Mailgun
body: <p>Emails to one of my users are periodically failing on Mailgun with the error <code>smtp; 550 Messages should have one or no Reply-To headers, not 2</code>:</p>
  
  <p>I can't see my <code>Reply-To</code> header in the Mailgun logs, but I'm reasonably certain I can only be sending one email in the <code>Reply-To</code> header. Here's my Ruby on Rails code that conditionally sets that header:</p>
  
  <pre class="lang-rb prettyprint-override"><code>    folder_emails = @fileuploads.map do |f|
        f.folder =~ /([\w+\-.]+@[a-z\d\-.]+\.[a-z]+)/i
        Regexp.last_match(1)
      end.compact.uniq
      email_params[:reply_to] = folder_emails.first if folder_emails.size == 1
  </code></pre>
  
  <p>If the <code>:reply_to</code> field isn't set in that code, it defaults to a default <code>reply-to</code> defined in my <code>ApplicationMailer</code>.</p>
  
  <p>I'm using the <code>mailgun-ruby</code> gem to deliver mail (<code>config.action_mailer.delivery_method = :mailgun</code>).</p>