Reputation: 33378
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 <[email protected]>"
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?
Upvotes: 0
Views: 1922
Reputation: 31
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
Upvotes: 3
Reputation: 3265
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: '[email protected]',
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
.
Upvotes: 1