dtjzpg5313 2016-12-30 15:36
浏览 16
已采纳

too long

I'm using Laravel 5.3 and the SES driver in order to send my emails. I've set up my database and routes so that, whenever I send an email that returns as a bounce, I get a notification and add this email to a table of "invalid emails".

Now I need to setup my app so it only sends an email if the email is NOT in this bounce table. It's a check that will be made for every single email sent by this app, with no exceptions.

Is there an easy way to make this check on the email driver, or do I need to change all calls to the Mail facade and check this before sending the email?

  • 写回答

1条回答 默认 最新

  • doufei0933 2016-12-30 17:06
    关注

    I'd suggest creating your own Mailable class which inherits from \Illuminate\Mail\Mailable.

    There is a method there called buildRecipients() which looks like this:

    /**
     * Add all of the recipients to the message.
     *
     * @param  \Illuminate\Mail\Message  $message
     * @return $this
     */
    protected function buildRecipients($message)
    {
        foreach (['to', 'cc', 'bcc', 'replyTo'] as $type) {
            foreach ($this->{$type} as $recipient) {
                $message->{$type}($recipient['address'], $recipient['name']);
            }
        }
    
        return $this;
    }
    

    You could hook in to (override) this and add some logic to only add the recipient if he is not on the "blocked" list.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号