如何使用默认Laravel模板发送电子邮件



如何使用默认模板在Laravel上发送电子邮件??

我在默认的HTML模板中的意思是与用于重置密码的模板相同的模板...

请问吗??

如果您使用的是Laravel 5.3或5.4,则应首先使用以下方式发布邮件视图:

php artisan vendor:publish --tag=laravel-mail 

将把刀片文件复制到资源/视图/供应商/邮件。然后,您可邮寄类的构建方法可以调用所需的邮件模板。

/**
 * Build the message.
 *
 * @return $this
 */
public function build()
{
    return $this->from('example@example.com')
                ->view('emails.orders.shipped');
}

有关更多详细信息,请参见文档。

这是我使用与Laravel发行的邮件类发送电子邮件的方式。

$user = PlaceUserObjectHere;
$emailType = 'Comment';
$emailView = 'emails.standardTemplate';
$emailContent = PlaceContent Object here;
$emailContent['Content'] = 'Place Email Body Here';
$emailSubject = 'Place Subject Line Here ';
$emailContent['Header'] = $emailSubject;
$emailContent['buttonURL'] = '/';
$emailContent['buttonTitle'] = 'Button Text';
Mail::send($emailView, ['user' => $user, 'emailContent' => $emailContent], function ($m) use ($user, $emailSubject) {
                $m->from('support@email.com', 'emailName');
                $m->to($user->first()->email, $user->first()->fname . ' ' . $user->first()->lname)->subject($emailSubject);
            });

这是标准时间板。

<div class='container' text-align="center">
    <h3 class="panel-title navbar-brand">{!! $emailContent['Header'] !!}</h3>
{!! $emailContent['Content'] !!}
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center">
      <div>
        <a href="{{url($emailContent['buttonURL'])}}" style="background-color:#2a3e68;border:1px solid #2a3e68;border-radius:3px;color:#ffffff;display:inline-block;font-family:sans-serif;font-size:16px;line-height:44px;text-align:center;text-decoration:none;width:300px;-webkit-text-size-adjust:none;mso-hide:all;">{{$emailContent['buttonTitle']}}</a>
      </div>
    </td>
  </tr>
</table>
@include('emails.partial.footer')
        </div>

希望这会有所帮助。

最新更新