my rails app use russian cyrryllic domain name (.рф), and there I have mailer, where i have default from section...
我的rails应用程序使用俄语cyrryllic域名(.рф),并在那里我有邮件,我有默认从部分...
like this:
喜欢这个:
default from: "noreply@портал.рф"
some part of mailer:
邮件的某些部分:
class CarMailer < ActionMailer::Base
default from: "noreply@портал.рф"
def send_car_question_back(question_text, question_email, question_phone, car_user, car)
****
mail(to: @question_email, subject: "***")
end
end
but on my mailbox i get noreply@blablabla with some strane numbers( like spam :)
但是在我的邮箱上,我得到了一些诽谤@ blablabla与一些strane数字(如垃圾邮件:)
are there any ways to send mail, and put sender in cyryllic format?
有没有办法发送邮件,并将发件人置于cyryllic格式?
in env confg i have:
在env confg我有:
config.action_mailer.smtp_settings = {
:enable_starttls_auto => false,
:address => 'localhost',
:port => 25,
:domain => 'xn----7s454545*****i',
:authentication => :login,
:content_type => "text/html",
:user_name => 'noreply@xn----7s454545*****i',
:password => '*****'
}
config.action_mailer.default_url_options = { :host => 'xn----7s454545*****i' }
1 个解决方案
#1
3
That 'xn----7s454545*****i'
is normal domain encoding for cyrillic domains, exactly for non-ASCII domains. The domain names conversion approach is described in RFC 3490.
'xn ---- 7s454545 ***** i'是西里尔域的正常域编码,完全适用于非ASCII域。域名转换方法在RFC 3490中描述。
Your mailbox just isn't support non-ASCII domain conversion. So you just can try to set domain name in mailer settings as a cyrillic one, and using a IDNA conversion gems to convert it to an ASCII form:
您的邮箱不支持非ASCII域转换。因此,您可以尝试将邮件设置中的域名设置为西里尔语,并使用IDNA转换gems将其转换为ASCII格式:
-
For ruby-1.8 it is the
idn
gem .对于ruby-1.8,它是idn宝石。
require 'idn'
And environment config:
和环境配置:
config.action_mailer.smtp_settings = { #... :domain => IDN::Idna.toASCII('портал.рф') }
And vise-versa:
反之亦然:
puts 'Idna.toUnicode: ' + IDN::Idna.toUnicode('xn--rksmrgs-5wao1o.josefsson.org')
-
For ruby-2.0 you have to use
simpleidn
gem.对于ruby-2.0,你必须使用simpleidn gem。
require 'idn' SimpleIDN.to_ascii("портал.рф") SimpleIDN.to_unicode("xn--mllerriis-l8a.com")
#1
3
That 'xn----7s454545*****i'
is normal domain encoding for cyrillic domains, exactly for non-ASCII domains. The domain names conversion approach is described in RFC 3490.
'xn ---- 7s454545 ***** i'是西里尔域的正常域编码,完全适用于非ASCII域。域名转换方法在RFC 3490中描述。
Your mailbox just isn't support non-ASCII domain conversion. So you just can try to set domain name in mailer settings as a cyrillic one, and using a IDNA conversion gems to convert it to an ASCII form:
您的邮箱不支持非ASCII域转换。因此,您可以尝试将邮件设置中的域名设置为西里尔语,并使用IDNA转换gems将其转换为ASCII格式:
-
For ruby-1.8 it is the
idn
gem .对于ruby-1.8,它是idn宝石。
require 'idn'
And environment config:
和环境配置:
config.action_mailer.smtp_settings = { #... :domain => IDN::Idna.toASCII('портал.рф') }
And vise-versa:
反之亦然:
puts 'Idna.toUnicode: ' + IDN::Idna.toUnicode('xn--rksmrgs-5wao1o.josefsson.org')
-
For ruby-2.0 you have to use
simpleidn
gem.对于ruby-2.0,你必须使用simpleidn gem。
require 'idn' SimpleIDN.to_ascii("портал.рф") SimpleIDN.to_unicode("xn--mllerriis-l8a.com")