ruby-on-rails 是否有任何方法来确认邮件发送的smtp在行动邮件?

mjqavswn  于 2023-05-30  发布在  Ruby
关注(0)|答案(1)|浏览(154)

Action mailer通过sendgrid发送电子邮件,带有smtp设置,我可以通过sengrid的webhook获得发送确认,有些电子邮件发送到sengrid,有些-看起来没有,例如我们发送了100封电子邮件,sendgrid说他们收到了97封,所以3封就消失了
也许有办法得到确认邮件的行动后,行动回调?

blpfk2vs

blpfk2vs1#

可以使用after_action
请检查以下示例:

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

相关问题