所以我遇到的问题是,从开发服务器发送的图像会显示在电子邮件中,但是在生产/暂存模式下发送时,图像不会显示在电子邮件中,但是在复制图像时来自电子邮件源的URL我可以在浏览器中显示图像。我有另一个应用程序与几乎相同的production.rb文件一起运行,它发送的图像没有问题,所以我不确定我错过了什么。
Rails.application.configure do
config.cache_classes = false
config.eager_load = false
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
host = 'development.local'
config.action_mailer.default_url_options = { host: host, protocol: 'https' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.asset_host = 'https://development.local'
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: "gmail.com",
user_name: ENV["GMAIL_USER"],
password: ENV["GMAIL_PASS"],
authentication: :plain,
enable_starttls_auto: true
}
config.active_support.deprecation = :log
config.active_record.migration_error = :page_load
config.assets.debug = true
config.assets.digest = true
config.assets.raise_runtime_errors = true
config.web_console.whitelisted_ips = '172.17.0.0/16'
config.web_console.whitelisted_ips = '0.0.0.0/0.0.0.0'
end
Rails.application.configure do
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.assets.js_compressor = :uglifier
config.assets.compile = false
config.assets.digest = true
config.force_ssl = true
config.log_level = :debug
config.action_controller.asset_host = 'https://production.local'
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
host = "production.local"
config.action_mailer.asset_host = 'https://production.local'
config.action_mailer.default_url_options = { host: host, protocol: 'https' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => ENV["GMAIL_USER"],
:password => ENV["GMAIL_PASS"],
:authentication => :plain,
:enable_starttls_auto => true
}
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
config.log_formatter = ::Logger::Formatter.new
config.active_record.dump_schema_after_migration = false
end
<div style="overflow:hidden;max-width:600px;margin:auto;border-radius:7px;box-sizing:border-box;box-shadow:0 6px 12px rgba(0, 0, 0, 0.175);">
<div style="overflow:hidden;background:#a1cbd6;color:#603914;padding:10px 20px;box-sizing: border-box;">
<%= image_tag('logo_h.png', style: "float:left;") %> <h1 style="float:left;margin:15px 15px 5px;">Test Company</h1>
</div>
<div style="overflow:hidden;background:#fff;padding:25px;box-sizing: border-box;">
<p>Hi <%= @user.name %>,</p>
<p>This account allows you to access everything you need</p>
<p>Activate your account by clicking the link below:</p>
<%= link_to "Activate", edit_account_activation_url(@user.activation_token, email: @user.email) %>
</div>
</div>