How to change the settings of Content-Transfer-Encoding mail program in Rails?

By default, Content-Transfer-Encoding is set to 7 bits. The Postfix mail server breaks the email header into several thousand characters, which means that if you have a long email (for example, using HTML), you end up with spaces in the middle of your text or links. (See This Topic for more information: http://tech.groups.yahoo.com/group/postfix-users/message/273296 )

Following the Rails ActionMailer documentation (http://api.rubyonrails.org/classes/ActionMailer/Base.html), adding the following code to the application file should do it, but that doesn't work:

ActionMailer::Base.default 'Content-Transfer-Encoding' => 'quoted-printable'

I still get the default:

 Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="--==_mimepart_50166adf1e043_1b9810829142282d"; charset=UTF-8 Content-Transfer-Encoding: 7bit 

My email looks like this:

 def new_registered_user(user_id) @user = User.find(user_id) set_locale @user.locale mail( :subject => i18n_subject, :to => @user.email_with_name ) do |format| format.text { render :layout => 'text_email' } format.html end end 

Any idea on what else I should change?

+6
source share
2 answers

I found that setting (undocumented) transport_encoding in the mail object works:

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

I could not get a documented approach to setting up Content-Transfer-Encoding with ActionMailer.

My environment: rails (3.1), mail (~> 2.3.3)

+7
source

If you use a custom mail program class, you can set it as the default parameter in your mail class, as described in the ActionMailer :: Base documentation

 class Notifier < ApplicationMailer default 'Content-Transfer-Encoding' => '7bit' end 
0
source

Source: https://habr.com/ru/post/921663/


All Articles