PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Written By
Views

Send Laravel notification email to non-registered user

Send Laravel notification email to non-registered user

Hey there.

Today I'm gonna show you how to send email notifications to any user email.

Normally, when you send email notifications in laravel, use the function notify, included in the main User model, like this:

<?php

$user->notify(new FormContact($form));

So, how can we send an email notification if we don't have the user registered?

Imagine that you have a typical contact form inside your website, normally you send an email to your main account (which may be registered), and also you would like to send a Thank you email to the user that sent the form.

So to do that in Laravel, we only have to notify the user with Notification class, like this:


<?php

Notification::route('mail', '[email protected]')
              ->notify(new FormContact($form));

Simple and useful trick.

Thank you!

Comments (0)

loading comments