I'm trying to send to my users an email when they register, I created a mailable class:
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class WelcomeMail extends Mailable
{
use Queueable, SerializesModels;
public $user;
public $message;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($user)
{
$this->user = $user;
$this->message = (new MailMessage)
->greeting('Bonjour '.$user->name)
->line('Nous vous remercions de votre inscription.')
->line('Pour rappel voici vos informations :')
->line('Mail: '.$user->email)
->line('Password: '.$user->password);
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->view('message')->with([
'slot' => $this->message
]);
}
But if I use a custom template I have to do all the css and Html, I see that the forgot password email uses a MailMessage, and all the templates are already made with the MailMessage template.
Is there any way for me to use the same template or directly create a MailMessage template but with my custom content?
Thanks.
Laravel provides drivers for SMTP, Mailgun, Mandrill, SparkPost, Amazon SES, PHP's mail function, and sendmail , allowing you to quickly get started sending mail through a local or cloud based service of your choice.
If failures() doesn't return anything then it has been successfully sent.
Publish notifications from vendor and you can send it in markdown
public function __construct($user)
{
$this->user = $user;
$this->message = (new MailMessage)
->greeting('Bonjour '.$user->name)
->line('Nous vous remercions de votre inscription.')
->line('Pour rappel voici vos informations :')
->line('Mail: '.$user->email)
->line('Password: '.$user->password);
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->markdown('vendor.notifications.email', $this->message->data());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With