/**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $email = Email::where(['id' => $id])->firstOrFail();
     $previewLink = action('\\Laramailer\\Controllers\\EmailController@show', ['id' => $id]);
     return view($email->template, $email, ['previewLink' => $previewLink]);
 }
Example #2
0
 /**
  * Sends the email with the data which was defined
  */
 public function send()
 {
     $saveData = ['to' => $this->to['email'], 'subject' => $this->subject, 'content' => json_encode($this->data), 'template' => $this->template];
     // Store the email for reference
     $email = Email::create($saveData);
     // Finishing touches on data
     $saveData['previewLink'] = action('\\Laramailer\\Controllers\\EmailController@show', ['id' => $email->id]);
     $saveData['content'] = json_decode($saveData['content'], true);
     $sendVerb = 'send';
     if ($this->queue) {
         $sendVerb = 'queue';
     }
     // Send the customer a confirmation email
     Mail::$sendVerb($this->template, $saveData, function ($m) use($saveData) {
         $m->from(getenv('MAIL_NOREPLY'), getenv('MAIL_NOREPLY_NAME'));
         $m->to($this->to['email'], $this->to['name'])->subject($this->subject);
     });
 }