Laravel 5.4 邮件消息如何编辑页眉和页脚

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45929579/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 16:33:57  来源:igfitidea点击:

Laravel 5.4 mail messages how to edit header and footer

phplaravellaravel-5.4

提问by Jaaayz

Hi I am trying to use MailMessage function in my Laravel App. My question is very simple. How to edit the Header and the Footer when receiving email from the app? Here is the picture below.

嗨,我正在尝试在我的 Laravel 应用程序中使用 MailMessage 功能。我的问题很简单。从应用程序接收电子邮件时如何编辑页眉和页脚?这是下面的图片。

enter image description here

在此处输入图片说明

I want to change the header Laravel from my App name and the Hello with a Hello $user->name and the Regards, with my App name also and the footer below to the App name also.

我想将标题 Laravel 从我的应用程序名称和带有 Hello $user->name 的 Hello 和问候,以及我的应用程序名称和下面的页脚更改为应用程序名称。

enter image description here

在此处输入图片说明

I tried to change the `

我试图改变`

resources/views/vendor/mail/markdown/message.blade.php

资源/视图/供应商/邮件/markdown/message.blade.php

To:

到:

@component('mail::layout')
    {{-- Header --}}
    @slot('header')
        @component('mail::header', ['url' => config('app.url')])
            CCTV App
        @endcomponent
    @endslot

    {{-- Body --}}
    {{ $slot }}

    {{-- Subcopy --}}
    @isset($subcopy)
        @slot('subcopy')
            @component('mail::subcopy')
                CCTV Team
            @endcomponent
        @endslot
    @endisset

    {{-- Footer --}}
    @slot('footer')
        @component('mail::footer')
            ? {{ date('Y') }} CCV3. All rights reserved.
        @endcomponent
    @endslot
@endcomponent

But not working when I send a reset password request Would really appreciate if someone can help me. Thanks in advance.

但是当我发送重置密码请求时不起作用,如果有人能帮助我,我将不胜感激。提前致谢。

`

`

回答by jogesh_pi

I want to change the header Laravel from my App name and the Hello with a Hello $user->name and the Regards, with my App name also and the footer below to the App name also

我想将标题 Laravel 从我的应用程序名称和带有 Hello $user->name 的 Hello 和问候,以及我的应用程序名称和下面的页脚更改为应用程序名称

Mailable Markdown by default has the config('app.name')that picks the APP_NAMEfrom your .env file. So by modifying the APP_NAMEwill effect on your markdown template.

可邮寄降价默认情况下有config('app.name')是采APP_NAME从您的.ENV文件。因此,通过修改APP_NAME将影响您的降价模板。

OR if you modifying it manually, run the following command on your terminal
php artisan vendor:publish --tag=laravel-mailand go to the resources/views/vendor/mail/html/message.blade.phpand modify the header and footer slot.

或者,如果您手动修改它,请在您的终端上运行以下命令
php artisan vendor:publish --tag=laravel-mail并转到resources/views/vendor/mail/html/message.blade.php并修改页眉和页脚插槽。

For changing Hello to Hello {user_name}, there is markdown called greeting()method that holds Hello!, you can change it whatever you want.

要将Hello更改为Hello {user_name},有一个称为greeting()方法的降价方法Hello!,您可以随意更改它。

For Regardsrun this command on your terminal
php artisan vendor:publish --tag=laravel-notificationsand go to the resources/views/vendor/notifications/email.blade.phpand modify the Regardswhatever you want.

对于问候,在您的终端上运行此命令,
php artisan vendor:publish --tag=laravel-notifications然后转到resources/views/vendor/notifications/email.blade.php并修改您想要的任何问候

To know more in details take a look on customizing markdown email.

要了解更多详细信息,请查看自定义降价电子邮件

回答by Jaaayz

I already figure it out just change the name of the env file to your App name instead of laravel. This is the sample below.

我已经想通了,只需将 env 文件的名称更改为您的应用程序名称而不是 laravel。这是下面的示例。

APP_NAME=Laravel

Change it to

将其更改为

APP_NAME=YOUR_APP_NAME

there is also one way to edit your mail template. Just go to resources/views/vendor/notifications/email.blade.phpand you can also edit the message to your mail just go to resources/views/vendor/markdown/message.blade.php

还有一种方法可以编辑您的邮件模板。只需转到resources/views/vendor/notifications/email.blade.php,您也可以将消息编辑到您的邮件中,只需转到resources/views/vendor/markdown/message.blade.php

回答by Yevgeniy Afanasyev

You are using default component for your email template named @component('mail::message'), It does not allow you to modify header. But if you go to the file of this component,

您正在为名为 的电子邮件模板使用默认组件@component('mail::message'),它不允许您修改标题。但是如果你去这个组件的文件,

\vendor\laravel\framework\src\Illuminate\Mail\resources\views\markdown\message.blade.php

you will notice that it uses another component @component('mail::layout'),

你会注意到它使用了另一个组件@component('mail::layout')

Just copy content of message.blade.phpfile into your .blade.phpand replace {{ $slot }}with what you had in your file before.

只需将message.blade.php文件内容复制到您的文件中.blade.php并替换{{ $slot }}为您之前文件中的内容即可。

And you are done.

你已经完成了。