@openxy
2016-03-14T20:53:56.000000Z
字数 1590
阅读 1808
未分类
ret = Kernel.open("| php ./php/export.php",'w+b') do |f|
f.write(json)
end
首先使用
rails g mailer XMailer
生成相关的代码,可参考上面链接中的说明;
>下面的代码主要为smtp配置及调试相关
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :letter_opener
gem "letter_opener"
ActionMailer::Base.smtp_settings = {
:address => "smtp.qq.com",
:port => 25,
:domain => "x.com",
:user_name => "xxx@qq.com",
:password => "xxxx",
:authentication => "plain",
:enable_starttls_auto => true,
# https://github.com/rails/rails/issues/892
# :openssl_verify_mode => 'none'
}
ActionMailer::Base.default_url_options[:host] = "localhost:3000"
# use letter_opener gem for devlopment
require "development_mail_interceptor"
Mail.register_interceptor(DevelopmentMailInterceptor) if Rails.env.development?
class DevelopmentMailInterceptor
def self.delivering_email(message)
message.subject = "to:#{message.to}: #{message.subject}"
#message.to = Rails.env.development? ? "xxx@qq.com" : "xxx2@qq.com"
message.to = "xxx@qq.com"
message.cc = "xxx@qq.com"
end
end