lib/sendgrid_actionmailer_adapter/delivery_method.rb
# Deliver a mail via SendGrid Web API.
#
# This method is called from Mail::Message#deliver!.
#
# @param [Mail::Message] mail Mail::Message object which you want to send.
# @raise [SendGridActionMailerAdapter::ValidationError] when validation error occurred.
# @raise [SendGridActionMailerAdapter::ApiError] when SendGrid Web API returns error response.
Deliver a mail via SendGrid Web API.
This method is called from Mail::Message#deliver!.
Deliver a mail via SendGrid Web API . This method is called from Mail :: Message#deliver! .
def deliver!(mail)
      sendgrid_mail = ::SendGridActionMailerAdapter::Converter.to_sendgrid_mail(mail)
      if mail[:remove_from_bounces]
        remove_to_addrs_from_bounces(sendgrid_mail)
      end
      with_retry(**@settings[:retry]) do
        @logger.info("Calling sendMail API, #{extract_log_info(sendgrid_mail)}")
        response = sendgrid_client.mail._('send').post(request_body: sendgrid_mail.to_json)
        @logger.info("End calling sendMail API, status_code: #{response.status_code}")
        handle_response!(response)
      end
    end
def deliver! ( mail ) sendgrid_mail = :: SendGridActionMailerAdapter :: Converter . to_sendgrid_mail ( mail ) if mail [ :remove_from_bounces ] remove_to_addrs_from_bounces ( sendgrid_mail ) end with_retry ( ** @settings [ :retry ] ) do @logger . info ( "Calling sendMail API, #{extract_log_info(sendgrid_mail)}" ) response = sendgrid_client . mail . _ ( 'send' ) . post ( request_body : sendgrid_mail . to_json ) @logger . info ( "End calling sendMail API, status_code: #{response.status_code}" ) handle_response! ( response ) end end
Deliver a mail via SendGrid Web API.
Deliver a mail via SendGrid Web API .
[SendGridActionMailerAdapter::ValidationError] when validation error occurred.
[ SendGridActionMailerAdapter :: ValidationError ] when validation error occurred .
[SendGridActionMailerAdapter::ApiError] when SendGrid Web API returns error response.
[ SendGridActionMailerAdapter :: ApiError ] when SendGrid Web API returns error response .
mail
<not_specific>
<not_specific>
mail Mail::Message object which you want to send.
mail Mail :: Message object which you want to send .