1. Go to this page and download the library: Download bronanza/laravel-emailer library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bronanza / laravel-emailer example snippets
public function register()
{
$this->app->singleton(
'Bronanza\Emailer\Contracts\Emailer',
'Bronanza\Emailer\LaravelEmailer'
);
}
namespace App\Http\Controllers;
use Illuminate\Mail\Message;
use Bronanza\Emailer\Contracts\Email;
use App\User;
class UserEmail implements Email
{
/**
* Show the profile for the given user.
*
* @param int $id
* @return Response
*/
public function __construct(User $user)
{
$this->user = $user;
}
// View that will be used for the email
public function template()
{
return 'email.email-test';
}
// Data that will be used in the view
public function templateData()
{
return [
'user' => $this->user,
];
}
public function setup()
{
return function (Message $message) {
$customerSupport = [
'email' => '[email protected]',
'name' => 'apeng'
];
$subject = 'Test Sending Email';
return $message
->from($customerSupport['email'], $customerSupport['name'])
->to($this->user->email, $this->user->first_name)
->bcc($customerSupport['email'])
->subject($subject);
};
}
}
namespace App\Http\Controllers;
use App;
use App\User;
use App\Http\Controllers\Controller;
use Bronanza\Emailer\Contracts\Emailer;
use App\Http\Http\Controller\UserEmail;
class SendEmail
{
protected $emailer;
/**
* instantite the emailer interface
**/
public function __construct(Emailer $emailer)
{
$this->emailer = $emailer;
}
public function index()
{
// Create a new Email object that contains the configuration
$email = App::make('App\Http\Controllers\UserEmail');
// Send the email
$this->emailer->send($email);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.