<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
skitlabs / laravel-mailgun-multiple-domains example snippets
declare(strict_types=1);
// app/Mail/ImportantMessage.php
class ImportantMessage extends \Illuminate\Mail\Mailable
{
public function build() : self
{
return $this
->subject('Important message')
->from('[email protected]') // The sender is often determined _inside_ the mailable
->view('...', []);
}
}
/** @var \App\Mail\ImportantMessage $mailable */
// Without this package, the calling code has to select the right mailer
\Illuminate\Support\Facades\Mail::mailer('mailgun-acme.tld')->to('[email protected]')->queue($mailable);
// This package will handle the mailer configuration for you. So the above is as simple as;
\Illuminate\Support\Facades\Mail::to('[email protected]')->queue($mailable);
declare(strict_types=1);
use Illuminate\Support\ServiceProvider;
use SkitLabs\LaravelMailGunMultipleDomains\Contracts\MailGunSenderPropertiesResolver;
// app/Providers/AppServiceProvider.php
class AppServiceProvider extends ServiceProvider
{
public function register()
{
// ...
$this->app->bind(MailGunSenderPropertiesResolver::class, static function () : MailGunSenderPropertiesResolver {
return new \Acme\CustomSenderPropertiesResolver();
});
}
}
declare(strict_types=1);
use Illuminate\Support\Facades\Config;
use SkitLabs\LaravelMailGunMultipleDomains\Contracts\MailGunSenderPropertiesResolver;
use SkitLabs\LaravelMailGunMultipleDomains\Listeners\ReconfigureMailGunOnMessageSending;
Config::set('mail.default', 'custom-mailer-name');
Config::set('mail.mailers.custom-mailer-name', [
'transport' => 'mailgun',
]);
/** @var MailGunSenderPropertiesResolver $resolver */
$handler = new ReconfigureMailGunOnMessageSending($resolver, 'custom-mailer-name');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.