JW_MAIL_METHOD=sync
return [
// Your config
'email' => [
/**
* Method send email
*
* Support: sync, queue, cron
* Default: sync
*/
'method' => env('JW_MAIL_METHOD', 'sync')
]
];
The Scheduler
on your server, hostingThe Scheduler
: Add command to your server* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
View more: Starting The Scheduler
$this->addAction(Action::INIT_ACTION, [$this, 'addEmailTemplates']);
public function addEmailTemplates()
{
$this->hookAction->registerEmailTemplate(
'email-template-code',
[
'subject' => 'subject',
'body' => "example::email.template",
'params' => [
'name' => 'User name',
],
]
);
}
use Juzaweb\Support\Email;
Email::make()
->withTemplate('email-template-code')
->setEmails('test@example.com')
->setParams([
'name' => 'Juzaweb',
])
->send();
Add to your file Action
namespace Vendor\Name\Actions;
use Juzaweb\Abstracts\Action;
use Juzaweb\Backend\Facades\HookAction;
class YourAction extends Action
{
public function handle()
{
// Your code
$this->addAction(Action::INIT_ACTION, [$this, 'registerEmailHooks']);
}
public function registerEmailHooks()
{
HookAction::registerEmailHook(
'register_success',
[
'label' => trans('domain::content.email_hook_label'),
'params' => [
'param' => trans('domain::content.param_label'),
],
]
);
}
}
use Juzaweb\CMS\Events\EmailHook;
use Illuminate\Http\Request;
class YouController
{
public function register(Request $request)
{
// Your code
$name = $request->input('name');
$email = $request->input('email');
event(
new EmailHook(
'register_success',
[
'to' => [$email],
'params' => [
'param' => [
'name' => $name,
'email' => $email
],
],
]
)
);
}
}