【问题标题】:I can not send email from self package laravel - wrong template path我无法从自包 laravel 发送电子邮件 - 错误的模板路径
【发布时间】:2019-04-13 18:48:38
【问题描述】:

我正在尝试制作将发送电子邮件的 Laravel 包。
发布包后有我的文件夹结构
http://prntscr.com/nbddef
如您所见,我在那里有模板
但是当我尝试发送邮件时,我收到了这个异常:

 #message: "View [D:\OSPanel\domains\testPackage.loc\app.Widgets.views.template] not found."

我试图在我的代码中更改此模板路径,但没有帮助

<?php
namespace Imediasun\Widgets\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Contracts\Mail\Mailer as MailerContract;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class OrderSend extends Mailable
{
    use Queueable, SerializesModels;
    protected $order;
    public function __construct()
    {

        $this->sub='New Csv Import Received';
        $this->recipient='imediasun@gmail.com';
        $this->sender=['address'=>'imediasu1n@gmail.com','name'=>'Andrey'];
        $this->template=app_path() .'/Widgets/views/template';
        $this->exception=false;
    }
    public function build()
    {
            return $this->from($this->sender)->to($this->recipient)->subject($this->sub)->view($this->template);
    }


}

【问题讨论】:

  • 试试这个 app_path('Widgets/views/template');
  • 相同的结果抱歉查看 [D:\OSPanel\domains\testPackage.loc\app\Widgets.views.template] 未找到。

标签: php laravel email package


【解决方案1】:

这是一个承包商,你需要这样做

$this->template='Widgets::template';

【讨论】:

    猜你喜欢
    • 2016-08-24
    • 1970-01-01
    • 1970-01-01
    • 2018-07-08
    • 1970-01-01
    • 1970-01-01
    • 2015-05-09
    • 2013-12-02
    • 2022-01-21
    相关资源
    最近更新 更多