0

I'm on Rails 4 and I've got one mailer. This was created following the tutorial in the docs.

class UserMailer < ActionMailer::Base

@delivery_options = {
        user_name: 'user_name',
        password: 'password',
        address: 'smtp.sendgrid.net'
}

default from: "Auto <auto@mysite.me>"

def welcome_email (user, password)
    @user = user
    @password = password
    @url = "http://url.com"
    mail(to: @user.email, subject: "Welcome to my site", delivery_method_options: @delivery_options)
end

def project_invite_email (email, project)
    @project = project
    mail(to: email, subject: "#{@project.user.first_name} #{@project.user.last_name} requests a video from you", delivery_method_options: @delivery_options)
end

end

During the course of troubleshooting some deliverability issues, I found that some emails included different headers than others. It turned out that a combination of SPF, DKIM, and adjustments to the email copy were able to resolve the deliverability problems (many were previously caught by spam filters), but I'd still like to know more about how Rails is creating the headers for these emails.

For example, the second one includes this in the header: Content-Transfer-Encoding: 7bit but the first has this: Content-Transfer-Encoding: quoted-printable

As you can see, they both use the exact same configurations. The only difference is the content of the views (both have an HTML & text version).

Is rails adjusting the headers based on content?

emersonthis
  • 30,934
  • 52
  • 191
  • 328
  • @MZaragoza gets the badge for most pointless edit of all time: `'myusername'` -> `'user_name'` – emersonthis Sep 26 '13 at 12:17
  • i really did not wanted to that that edit, i wanted to include the beginning of the code `class UserMailer < ActionMailer::Base` into the code block i just notice the the last end is outside of the codeblock – MZaragoza Sep 26 '13 at 13:10

2 Answers2

3

Ok. I'll post it as a question next time. Thanks.

I've got this resolved now with the help of the other post.

How to change the mailer Content-Transfer-Encoding settings in Rails?

m = mail(...)
m.transport_encoding = "quoted-printable"
m.deliver
Community
  • 1
  • 1
1

Yes, rails automatically adjusts Content-Transfer-Encoding. If you have non-standard characters in your mailer view, the header may randomly switch between 7bit and quoted-printable (or just stick to quoted-printable).

If required, you can force the mailer to use the default encoding (7bit).

class Mailer < ActionMailer::Base
  default from: 'from@example.com',
          content_transfer_encoding: '7bit'

  ...
end

However it is most likely caused by an invalid character, which should be visible (such as Â) once you force the header to 7bit.

Oscar Barrett
  • 2,495
  • 29
  • 33