3

I want to edit my mail and change everything, if I want, as shown here.

Ive imported my file and created a test route to view the page:

use Illuminate\Mail\Markdown;

Route::get('/mail/html', function () {
    $markdown = new Markdown(view(), config('mail.markdown'));
    return $markdown->render('vendor.mail.html.message'); // or ..markdown.message
});

However, Im having variable errors for @slot. How to view my change/see what the mail looks like before sending? Another package for that?

Thanks

Sylar
  • 11,422
  • 25
  • 93
  • 166

3 Answers3

3

To preview your email in browser please add below code to route

Route::get('preview-notification', function () {
 $markdown = new \Illuminate\Mail\Markdown(view(), config('mail.markdown'));   
 $data = "Your data to be use in blade file";
 return $markdown->render("path-of-your-templete-blade-file", $data]);
}); 

and you will be access your templete using

http://your-application-url/preview-notification
waseem asgar
  • 664
  • 8
  • 20
1

This is the recommended way by the Laravel community

kunal has a nice quick solution and that's how I used to do it. But now I use mailtrap.io to test emails because it allows you to replicate the whole process of sending an email.

  1. Create a (free) account with mailtrap.io.
  2. Add your mailtrap username and password in .env file.

By the way, Laravel is already configured to use mailtrap by default, so it is their recommended way to test emails.

Watch how Jeffrey Ways does it in his lesson: Laravel 5.4 From Scratch: Sending Email

https://laracasts.com/series/laravel-from-scratch-2017/episodes/26

BassMHL
  • 8,523
  • 9
  • 50
  • 67
-2

If you want to test in locally. You can put echo command in blade file at end and put die; this way you can test.Suppose you have test-email.blade.php

test-email.blade.php // file name
This is tets mail
<?php echo "test"; die; ?>

Hope it helps!

kunal
  • 4,122
  • 12
  • 40
  • 75