Last active
June 25, 2020 00:54
-
-
Save tzkmx/9ea9c7afaac7a5cb66948ccdfd55b217 to your computer and use it in GitHub Desktop.
Minimal sending of Laravel Emails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MAIL_DRIVER=smtp | |
MAIL_HOST=smtp.sendgrid.net | |
MAIL_PORT=587 | |
MAIL_USERNAME=apikey | |
MAIL_PASSWORD=SG.xxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxx | |
MAIL_ENCRYPTION=tls | |
MAIL_FROM_ADDRESS="[email protected]" | |
MAIL_FROM_NAME="Hey Dude/tte" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Console\Commands; | |
use App\Mail\TestEmail; | |
use Illuminate\Console\Command; | |
use Illuminate\Support\Facades\Mail; | |
class SendNotificationTest extends Command | |
{ | |
/** | |
* The name and signature of the console command. | |
* | |
* @var string | |
*/ | |
protected $signature = 'sendnote:test'; | |
/** | |
* The console command description. | |
* | |
* @var string | |
*/ | |
protected $description = 'Command description'; | |
/** | |
* Create a new command instance. | |
* | |
* @return void | |
*/ | |
public function __construct() | |
{ | |
parent::__construct(); | |
} | |
/** | |
* Execute the console command. | |
* | |
* @return mixed | |
*/ | |
public function handle() | |
{ | |
$data = ['name' => 'Chuchito']; | |
Mail::to('[email protected]') | |
->send(new TestEmail($data)); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p>Este es un correo de prueba para {{ name }}</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Mail; | |
use Illuminate\Bus\Queueable; | |
use Illuminate\Contracts\Queue\ShouldQueue; | |
use Illuminate\Mail\Mailable; | |
use Illuminate\Queue\SerializesModels; | |
class TestEmail extends Mailable | |
{ | |
use Queueable, SerializesModels; | |
/** | |
* Create a new message instance. | |
* | |
* @return void | |
*/ | |
public function __construct(array $data) | |
{ | |
$this->viewData = $data; | |
} | |
/** | |
* Build the message. | |
* | |
* @return $this | |
*/ | |
public function build() | |
{ | |
return $this->view('emails.test'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment