Skip to content

Laravel handle incoming emails in your application

Catch incoming emails in your Laravel application via laravel-mailbox package for Laravel 5.7 and up that will allow your application to catch and react to incoming emails from different services like Mailgun, SendGrid or the local log driver for debugging purposes.

to listen incoming email messages in a Laravel-Route like fashion and react to them.

Mailbox::from('info@maildomain.com', function (InboundEmail $email) {
	$subject = $email->subject();
});

more: https://beyondco.de/docs/laravel-mailbox/getting-started/introduction

accessing email attributes and content

Mailbox::from('{username}@gmail.com', function (InboundEmail $email, $username){
    $subject = $email->subject();
    $email->reply(new ReplyMailable);
});

github: https://github.com/beyondcode/laravel-mailbox

Laravel create model, controller and migration in single artisan command

For Laravel 5.6 and older:

php artisan make:model Todo -mcr

-m, –migration Create a new migration file for the model.
-c, –controller Create a new controller for the model.
-r, –resource Indicates if the generated controller should be a resource controller

and for Laravel 5.7 and newer:

php artisan make:model Todo -a

-a, –all Generate a migration, factory, and resource controller for the model

or you can make model + migration + controller, all in one line, using this command:

php artisan make:model --migration --controller Todo

Output:

Model created successfully.

Created Migration: 2020_04_11_202633_create_todos_table

Controller created successfully.

and if you need to perform all CRUD operations in the controller then use this command:

php artisan make:model -mc Todo --resource

Register a user in Laravel manually

php artisan tinker

Adding a new user to user table with the model User().

$user = new App\User();
$user->password = Hash::make('password');
$user->email = 'email@example.com';
$user->name = 'Name';
$user->save();