Comments (3)
I'll see if I can figure it out after watching the Mailables lesson on Laracasts.
from centaur.
Okay, got it sorted.
- Make a mailable with a suitable name e.g.
php artisan make:mail CentaurWelcomeEmail
- Edit App\Mail\CentaurWelcomeEmail to look like this:
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class CentaurWelcomeEmail extends Mailable
{
use Queueable, SerializesModels;
public $email;
public $code;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($email, $code)
{
$this->email = $email;
$this->code = $code;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->
->subject('Your account has been created!')
->view('centaur.email.welcome');
}
}
- In App\Http\Controllers\UserController and App\Http\Controllers\Auth\RegistrationController replace the following (in the store method and postRegister method respectively)
Mail::queue(
'centaur.email.welcome',
['code' => $code, 'email' => $email],
function ($message) use ($email) {
$message->to($email)
->subject('Your account has been created');
}
);
with the following
Mail::to($email)->queue(new CentaurWelcomeEmail($email, $code));
(how nice does that look)
- be sure to make sure you add the following to the top of each controller
use App\Mail\CentaurWelcomeEmail;
-
Do similar for any other existing mail sent by controllers (poss just reset email - haven't looked yet).
-
View mailable documentation here https://laravel.com/docs/5.4/mail#queueing-mail for any other preferential changes.
Would be nice for new users when this is set up by default.
from centaur.
Thanks for your pull request! I made some additional tweaks to the namespace references and the test assertions to get the tests passing. Your mailables have been included in v4.0.2.
from centaur.
Related Issues (20)
- Centaur redirecting to wrong place HOT 2
- Laravel 5.4 support? HOT 1
- Illuminate\Console\AppNamespaceDetectorTrait not found HOT 1
- How can i use correctly remember me HOT 4
- Allowing users to edit only their own articles HOT 4
- Only mailables may be queued. InvalidArgumentException in Mailer.php line 326: HOT 1
- Social login HOT 2
- Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required" HOT 6
- Laravel 5.5 support? HOT 3
- Invalid credentials error is not shown HOT 3
- Need help at upgrading from rydurham/Sentinel HOT 5
- Loop after role deletion HOT 2
- Laravel 5.7 release HOT 2
- Activation route redirects to error page HOT 2
- Account Not Yet Activated Debug page Change HOT 7
- Laravel 6 ( Swift_TransportException (530) Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required ") HOT 3
- Laravel 7, Centaur 10 - "DetectsApplicationNamespace" HOT 2
- Laravel 8 and Cartalyst 5 support. HOT 1
- Dear Centaur can you please let me know when php 8.0 support will be available? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from centaur.