"默认情况下,“Content-Transfer-Encoding”设置为“7bit”。邮件服务器Postfix将电子邮件标题分解为一堆1000个字符,这意味着如果您有一个长的电子邮件(例如使用HTML),您最终会在文本或链接中间出现空格。(有关更多信息,请参见此线程:http://tech.groups.yahoo.com/group/postfix-users/message/273296)
根据Rails ActionMailer文档(http://api.rubyonrails.org/classes/ActionMailer/Base.html),将以下代码添加到我的应用程序文件中应该可以解决问题,但实际上并没有起作用:
根据Rails ActionMailer文档(http://api.rubyonrails.org/classes/ActionMailer/Base.html),将以下代码添加到我的应用程序文件中应该可以解决问题,但实际上并没有起作用:
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
你有没有想过还需要做哪些改变?
m.transport_encoding =“base64”
而不是m.transport_encoding =“quoted-printable”
,因为我们必须发送包含外语字符的邮件,而根据维基百科:“Base64 ...是二进制格式或非拉丁语言文字的更明智的选择。”来自https://en.wikipedia.org/wiki/Quoted-printable - ryan2johnson9