簡體   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. 首先,我轉到這個文件“C:\xampp\htdocs\clinique_juridique\vendor\laravel\framework\src\Illuminate\Auth\Notifications\VerifyEmail.php”,然后翻譯那里的句子。 這里我遇到了兩個問題,第一個有些句子沒有在 VerifyEmail.php 所以我不能翻譯第二個,我不知道如何改變消息的樣式,當然,我也沒有知道如何包括我的網站的標志。 先感謝您。

所以我認為您是在詢問代碼的這個特定部分(取自 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 .

否則,如果您想讓它更復雜,您可以創建自己的 class MyVerifyEmail 擴展 VerifyEmail 並重新創建 toMail 方法以滿足您的需求,但我想不出您這樣做的場景。

其次,如果您想包含一些個性化的郵件樣式,請嘗試創建Mailable ,通過這種方法您可以使用自定義視圖(當然包括徽標)。

最后,我鼓勵不要修改供應商的目錄,因為它存儲了 laravel 正常工作所需的所有庫。 相反,擴展您可能想要修改的任何 class。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM