Module: SendgridSmtpApi
- Defined in:
- lib/sendgrid_smtp_api.rb
Overview
SendGrid SMTP API: +X-SMTPAPI+ JSON header for messages sent via +smtp.sendgrid.net+.
Replaces the legacy +sendgrid+ gem (stephenb/sendgrid). Phase 2: migrate to Mail Send v3 (+sendgrid-ruby+).
Defined Under Namespace
Modules: InternalMailerHeaders
Constant Summary collapse
- FILTER_NAMES =
%i[ opentrack clicktrack ganalytics gravatar subscriptiontrack footer spamcheck bypass_list_management ].freeze
Class Method Summary collapse
-
.build_x_smtpapi_header(unique_args: nil, disabled_filters: nil) ⇒ String
JSON for the +X-SMTPAPI+ header (may be +"{}"+).
Class Method Details
.build_x_smtpapi_header(unique_args: nil, disabled_filters: nil) ⇒ String
Returns JSON for the +X-SMTPAPI+ header (may be +"{}"+).
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/sendgrid_smtp_api.rb', line 22 def self.build_x_smtpapi_header(unique_args: nil, disabled_filters: nil) header_opts = {} header_opts[:unique_args] = unique_args if unique_args.present? if disabled_filters.present? filters = {} Array(disabled_filters).each do |name| sym = name.to_sym next unless FILTER_NAMES.include?(sym) filters[sym] = { 'settings' => { 'enable' => 0 } } end header_opts[:filters] = filters if filters.any? end header_opts.to_json end |