使用不同的模板Laravel 5.7的自定义电子邮件验证

时间:2020-01-08 05:44:27

标签: laravel laravel-5.7 laravel-authentication

我正在尝试发送两个不同的电子邮件验证(包括模板),具体取决于注册用户的身份。 我想拥有两个不同的电子邮件验证模板,这些模板可以通过用户并进行模板降价处理,但是我无法使自定义工作。 我确实尝试了所有的stackoverflow答案,并尝试了laracastmedium。不幸的是,没有运气!

那么到目前为止我做了什么:

1)在启动的AppServiceProvider中,我添加了以下导致此错误的代码

Call to undefined method App\Providers\AppServiceProvider::verificationUrl()


use Illuminate\Auth\Notifications\VerifyEmail;
use Illuminate\Notifications\Messages\MailMessage;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
      \Blade::setEchoFormat('e(utf8_encode(%s))');

    VerifyEmail::toMailUsing(function ($notifiable) {
            $verifyUrl = $this->verificationUrl($notifiable);
            return (new MailMessage)
                ->subject('Verify your email address')
                ->markdown('emails.verify', ['url' => $verifyUrl]);
        });
    }
  }

2)我要做的第二件事是将public function sendEmailVerificationNotification()添加到用户模型

          public function sendEmailVerificationNotification()
                {

    \Illuminate\Auth\Notifications\VerifyEmail::toMailUsing(function ($notifiable) {

        // this is what is currently being done
        // adjust for your needs

        return (new \Illuminate\Notifications\Messages\MailMessage)
            ->subject(\Lang::getFromJson('Verify Email Address'))
            ->line(\Lang::getFromJson('Please click the button below to verify your email address.'))
            ->action(
                \Lang::getFromJson('Verify Email Address'),
                $this->verificationUrl($notifiable)
            )
            ->line(\Lang::getFromJson('If you did not create an account, no further action is required.'));
                });

}

没有任何发送,也没有错误。我尝试过的任何其他解决方案也都死胡同,并且不会发送电子邮件或抛出错误。

0 个答案:

没有答案
相关问题