简体   繁体   English

如何自定义我的 Laravel email 验证信息

[英]How to customize my Laravel email verification message

during the conception of my web site using laravel 7 I found some troubles when I wanted to customize my laravel customize my Laravel email verification message. during the conception of my web site using laravel 7 I found some troubles when I wanted to customize my laravel customize my Laravel email verification message. first, I went to this file "C:\xampp\htdocs\clinique_juridique\vendor\laravel\framework\src\Illuminate\Auth\Notifications\VerifyEmail.php",then i translate the sentences that are there.首先,我转到这个文件“C:\xampp\htdocs\clinique_juridique\vendor\laravel\framework\src\Illuminate\Auth\Notifications\VerifyEmail.php”,然后翻译那里的句子。 Here I met two issues, the first one some sentences are not in VerifyEmail.php so I couldn't translate them the second one, I didn't know how to change the style of the message, of course, also I didn't know how to include the logo of my website.这里我遇到了两个问题,第一个有些句子没有在 VerifyEmail.php 所以我不能翻译第二个,我不知道如何改变消息的样式,当然,我也没有知道如何包括我的网站的标志。 thank you in advance.先感谢您。

So I think you're asking about this specific part of the code (took from Laravel 8 vendor code):所以我认为您是在询问代码的这个特定部分(取自 Laravel 8 供应商代码):


 /**
     * Build the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail($notifiable)
    {
        $verificationUrl = $this->verificationUrl($notifiable);

        if (static::$toMailCallback) {
            return call_user_func(static::$toMailCallback, $notifiable, $verificationUrl);
        }

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

First, you may use this class VerifyEmail and method toMail to send this confirmation email to your client, but if you look closer, you can identify that this function is using the Lang class, which can be found at Laravel Localization . First, you may use this class VerifyEmail and method toMail to send this confirmation email to your client, but if you look closer, you can identify that this function is using the Lang class, which can be found at Laravel Localization .

Otherwise, if you want to make it more complex you can create your own class MyVerifyEmail which extends VerifyEmail and recreate toMail method to serve your needs, but I can't think of a scenario where you do this.否则,如果您想让它更复杂,您可以创建自己的 class MyVerifyEmail 扩展 VerifyEmail 并重新创建 toMail 方法以满足您的需求,但我想不出您这样做的场景。

Second, if you want to include some personalized style of your mail, try creating a Mailable , with this approach you can use a custom view (of course including a logo).其次,如果您想包含一些个性化的邮件样式,请尝试创建Mailable ,通过这种方法您可以使用自定义视图(当然包括徽标)。

And finally, I encourage to do not to modify the vendor's directory, because it stores all the libraries that laravel needs to work properly.最后,我鼓励不要修改供应商的目录,因为它存储了 laravel 正常工作所需的所有库。 Instead, extend any class which you may want to modify.相反,扩展您可能想要修改的任何 class。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM