Is there any way to confirm email delivery by smtp at Action Mailer?

57 Views Asked by At

Action mailer sends email through sendgrid with smtp settings, I can get delivery confirmation by sengrid's webhook, and some emails delivered to sengrid, some - looks like not, for example we sent 100 emails and sendgrid said that they got 97, so 3 just disappeared

Maybe there is way to get confirmation in mailer's action in after action callback?

1

There are 1 best solutions below

1
Ronak Bhatt On

you can use after_action

Please check the following example :

class YourMailer < ActionMailer::Base
  after_action :check_email_delivery, only: [:your_action]

  def your_action
    # Your email generation code
  end

  private

  def check_email_delivery
    # Implement your custom logic to check email delivery status here
    # You can use SMTP libraries or services to verify the delivery
    # For example, you can use the `smtp_mail` gem to check delivery status

    # Update your database or perform other actions based on the delivery status
  end
end