🤹
TALL Stack Tips
  • What is TALL Stack
  • Tailwind
    • Tailwind Resources
    • Swinging Bell Notification Icon
    • Styled Unordered Lists
  • Alpine
  • Alpine Resources
  • Tabbed Content Using Alpine JS
  • Checkbox component with SVG tick
  • Dropdown animation
  • Create a Sliding Puzzle Captcha
  • Laravel
    • Tabler Icons Component
    • Password-less Login with Laravel 8+
    • Password-less Login with Magic Link in Laravel 8
    • Laravel Resources
    • Laravel Breeze Login Conditional Redirect
    • Jetstream Login Conditional Redirect
    • Simplify Laravel CRUD Controllers
    • CSRF and expired login forms
    • CSRF and expired logout forms
    • Add your own logo to Laravel Mail
    • Specify a different mail theme for Notifications
    • Show custom page when email verification link expired
    • Using a mutator to save currency
    • Using Spatie Valuestore to hold frequently accessed settings
    • Using the old() helper
    • Alternatives to using Eloquent Accessor
    • UpdateOrCreate may not update timestamp
    • Use of lockForUpdate()
    • Using S3
    • Super Simple User Based Feature Flags
    • Installing a Specific Version of Laravel
    • Versioning your Laravel Project
    • CSS Cache Busting with your Git Commit SHA
    • Adding column to Database Notifications table
    • Find nearby locations using the Haversine formula in Eloquent query
    • Using Queues on Shared Hosting with Laravel
    • Create Guaranteed Unique Invoice Number in Laravel
    • Send Notification to all team members
    • Protect Staging site with Basic Auth
    • Working with Enums
    • PHP DateTime formatting cribsheet
  • Livewire
    • Livewire Resources
    • Naming Livewire Components
    • Dynamic Cascading Dropdown with Livewire
    • Hiding a button after click
    • Working with Javascript Components
    • SweetAlert2 with Livewire
    • Select Multiple or Checkboxes
    • Clearing checkboxes in Livewire
    • Livewire File Uploads Using S3
    • Simple Log File Viewer
  • Related Resources
    • Testing resources
    • When Composer runs out of memory
    • Deployment
    • Security
    • Scheduler & Cron tips
    • LastPass tips
    • Using Git
    • VSCode Tips
    • Markdown
    • Cpanel resources
Powered by GitBook
On this page

Was this helpful?

  1. Laravel

Specify a different mail theme for Notifications

Where to place a custom mail theme in Laravel

PreviousAdd your own logo to Laravel MailNextShow custom page when email verification link expired

Last updated 1 year ago

Was this helpful?

This issue was resolved in Laravel 8.5

Views can use something called Hints to tell the framework where to look for the view file. The theme always uses a hint of Mail:: which corresponds to the resources/views/vendor/mail/html folder. What if we want to locate our theme somewhere else?

We can define our own hint and bind it into the system in the AppServiceProvider with;

app/Providers/AppServiceProvider.php
    public function boot()
    {
        $this->loadViewsFrom(resource_path('views/mail'), 'appmail');
    }

With this, we are saying that any view file that is hinted with appmail:: is found in the views/mail folder.

Then, in the Notification, add the hint in the theme function;

  public function toMail($notifiable)
  {
    return (new MailMessage)
      ->theme('appmail::mycorp')
      ->subject('Password Reset')
      ->line('Your password reset code is specified below')
      
    // etc

https://github.com/laravel/framework/issues/34391