Last active
May 5, 2020 12:01
-
-
Save deepak-cotocus/3c19e10978c4bc735cc0d816a2069166 to your computer and use it in GitHub Desktop.
This file contains 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\Http\Controllers; | |
use App\Http\Controllers; | |
use Mail; | |
use Illuminate\Http\Request; | |
use App\Mail\TestEmailSender; | |
use Illuminate\Support\Facades\Log; | |
class TestController extends Controller | |
{ | |
public $name; | |
public $email; | |
public function __construct() | |
{} | |
public function sendEmail() | |
{ | |
$this->name = "Deepak"; | |
$this->email = "deepak.cotocus@gmail.com"; | |
log::info("I am inside TestController->sendEmail()"); | |
$emailParams = new \stdClass(); | |
$emailParams->usersName = $this->name; | |
$emailParams->usersEmail = $this->email; | |
$emailParams->subject = "activate user of Demo-app - Activation Code"; | |
Mail::to($emailParams->usersEmail)->send(new TestEmailSender($emailParams)); | |
} | |
public function test(){ | |
$this->sendEmail(); | |
} | |
} | |
This file contains 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\Mail\Mailable; | |
use Illuminate\Queue\SerializesModels; | |
use Illuminate\Contracts\Queue\ShouldQueue; | |
use Illuminate\Support\Facades\Log; | |
use Illuminate\Support\Facades\Config; | |
class TestEmailSender extends Mailable | |
{ | |
use Queueable, SerializesModels; | |
private $emailParams; | |
/** | |
* Create a new message instance. | |
* | |
* @return void | |
*/ | |
public function __construct($params) | |
{ | |
$this->emailParams = $params; | |
} | |
/** | |
* Build the message. | |
* | |
* @return $this | |
*/ | |
public function build() | |
{ | |
log::info("I am inside Mail/UserActivationLinkMail->build()"); | |
$this->from(Config::get('app.senderEmail'),Config::get('app.senderName')) | |
->subject($this->emailParams->subject) | |
->view('mail.TestEmail') | |
->with(['emailParams' => $this->emailParams]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment