首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将View::make转换为电子邮件

如何将View::make转换为电子邮件
EN

Stack Overflow用户
提问于 2018-03-20 05:19:43
回答 1查看 38关注 0票数 0

在我的控制器中,我返回了这个视图,我正试图将其转换为如下所示的电子邮件。视图工作正常,但我的电子邮件没有发送。我不知道为什么。

代码语言:javascript
复制
 public function emailRegistrationConfirmation()
 {

    $user = Auth::user();
    $errors = Session::get('error');
    $warning = Session::get('warning');
    $info = Session::get('info');
    $success = Session::get('success');

    $return_mail = Config::get('mail.from.address');

    $attendeesIds = $user->attendees()->get()->lists('id');

    $programs = ScheduledProgram::whereHas('registeredAttendees', function($q) use ($attendeesIds){
                $q->whereIn('attendees.id', $attendeesIds);
              })->where('registration_start_date', '<=', $today)
                ->where('end_date',                '>=',  $today)
                ->get();


    $sent =  Mail::send('user/registration/show', compact( 'user','programs', 'programsProcessing', 'cart','errors', 'successes', 'info', 'warning'), function($message) use ($return_mail, $user)
    {

      $message->to($return_mail, 'Confirmations')
              ->subject('RECEIPT: ' . $user->first_name . ' ' . $user->last_name);
    });

    return $sent?'sent':'not sent';

    /*OLD return View worked fine*/
    return View::make('user/registration/show', compact('user','programs', 'programsProcessing', 'cart'))
          ->withError($errors)
          ->withSuccess($success)
          ->withInfo($info)
          ->withWarning($warning);
    }

我的页面返回not sent。我猜这意味着Mail::send失败了。PhpDebugBar显示在电子邮件选项卡中

代码语言:javascript
复制
Message-ID: &lt;f6d6143403eda66af66ada902039c149@dev.registration.innisfillibrary.ca&gt;
Date: Mon, 19 Mar 2018 16:43:27 -0400
Subject: RECEIPT: pwang1 wang
From: automailer &lt;registration@innisfillibrary.ca&gt;
To: Confirmations &lt;registration@innisfillibrary.ca&gt;
MIME-Version: 1.0
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
EN

回答 1

Stack Overflow用户

发布于 2018-03-20 14:53:17

在Laravel和emails.register中发送这样的超文本标记语言电子邮件意味着路径将是emails/register.blade.php

代码语言:javascript
复制
Mail::send(['html' => 'emails.register'], [
      'url' => url("set-password/some-verify-token"),
      'email' => $request->input('email')
   ], function ($mail) use($email) {
      $mail->from(env('SUPPORT_EMAIL'), env('APP_NAME'));
      $mail->to($email);
      $mail->subject('welcome');
});

返回文件路径错误,请将其user/registration/show更改为user.registration.show,文件路径将为user/registration/show.blade.php

代码语言:javascript
复制
return View::make('user.registration.show', compact('user','programs', 'programsProcessing', 'cart'))
          ->withError($errors)
          ->withSuccess($success)
          ->withInfo($info)
          ->withWarning($warning);
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49372512

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档