用电子邮件
\Mail::to( 方法在laravel 8应用程序中,我在im我的电子邮件模板中有html标记。
@component('mail::message')
<h3 >
You registered at {{ $site_mame }}
</h3>
Best regards, <br>
...
@endcomponent以及我的app/Mail/UserRegistered.php中的代码:
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class UserRegistered extends Mailable
{
use Queueable, SerializesModels;
public $site_mame;
public $user;
public $confirmation_code;
public function __construct( $site_mame, $user, $confirmation_code )
{
$this->site_mame = $site_mame;
$this->user = $user;
$this->confirmation_code = $confirmation_code;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->markdown('email.UserRegisteredEmail')
->with('site_mame', $this->site_mame)
->with('user', $this->user)
->with('confirmation_code', $this->confirmation_code);
}
}在我的.env文件中使用sendgrid选项,我在google帐户上得到了有效的emaul,但是html标记没有呈现。如果有一种方法来呈现所有html标记?它是否依赖于laravel应用程序/电子邮件选项,或设置在我的谷歌(或其他一些帐户)。我能从我身边做些什么?
更新的:修改的:
$this->view(我有错误:
No hint path defined for [mail]. (View: project/resources/views/email/UserRegisteredEmail.blade.php) 指向我的刀片文件。在网上搜索,我发现这是可能的决定:
php artisan vendor:publish --tag=laravel-mail并清除所有缓存
但我还是犯了同样的错误。我错过了一些选择吗?
提前感谢!
发布于 2021-12-31 06:18:50
您正在使用markdown()方法,它是一种在邮件中利用预先构建的模板和邮件通知组件的方法。
这提供了许多优点:
的开头放置一个#、##等
<ul>中包装列表,在<li>标记中列出项目。在标记中,您只需使用一个破折号(-)来列出元素的文本周围放置*/**来实现。
您可以在官方的Laravel文档中更多地了解到这一点。
https://laravel.com/docs/8.x/mail#markdown-mailables
如果您想使用HTML,可以只呈现一个视图:
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->view('email.UserRegisteredEmail')
->with('site_mame', $this->site_mame)
->with('user', $this->user)
->with('confirmation_code', $this->confirmation_code);
}https://stackoverflow.com/questions/70539369
复制相似问题