如何在Rails中更改邮件的Content-Transfer-Encoding设置? [英] How to change the mailer Content-Transfer-Encoding settings in Rails?
问题描述
默认情况下,"Content-Transfer-Encoding"设置设置为"7bit". 邮件服务器Postfix将一堆1000个字符分解为电子邮件标题,这意味着如果您的电子邮件很长(例如,使用HTML),则最终在文本或链接的中间会留有空格. (有关更多信息,请参见此线程: http://tech.groups.yahoo.com/group/postfix-users/message/273296 )
The 'Content-Transfer-Encoding' setting is set to '7bit' by default. The mail server Postfix is breaking down the email header by bunch of 1000 caracteres, meaning that if you have a long email (using HTML for example), you end up having spaces in the middle of your text or links. (See this thread for more info: http://tech.groups.yahoo.com/group/postfix-users/message/273296)
按照Rails ActionMailer文档(http://api.rubyonrails.org/classes/ActionMailer/Base.html),将以下代码添加到我的应用程序文件中应该可以,但是它不起作用:
Following the Rails ActionMailer documentation (http://api.rubyonrails.org/classes/ActionMailer/Base.html), adding the following code to my app file should make it, but it doesn't work:
ActionMailer::Base.default 'Content-Transfer-Encoding' => 'quoted-printable'
我仍然使用默认值:
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="--==_mimepart_50166adf1e043_1b9810829142282d";
charset=UTF-8
Content-Transfer-Encoding: 7bit
我的电子邮件如下:
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 should I change?
推荐答案
我发现在Mail对象上设置(未记录的)transport_encoding是可行的:
I found that setting the (undocumented) transport_encoding on the Mail object works:
m = mail(...)
m.transport_encoding = "quoted-printable"
m.deliver
我无法获得通过ActionMailer设置Content-Transfer-Encoding的文档化方法.
I could not get the documented approach of setting the Content-Transfer-Encoding via ActionMailer to work.
我的环境:护栏(3.1),邮件(〜> 2.3.3)
My environment: rails (3.1), mail (~> 2.3.3)
这篇关于如何在Rails中更改邮件的Content-Transfer-Encoding设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!