use Illuminate\Mail\Transport\Transport;
class MyMailTransport extends Transport
{
public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
{
$url = 'https://my.custome.email.service';
$data = [
"toAddress" => implode(',', array_keys($message->getTo())),
"subject" => $message->getSubject(),
"body" => $message->getBody()
];
#Send mail logic here :)
}
}
namespace App\Resolvers;
use App\Services\MyCustomMailTransport;
use Crystoline\CustomMailProvider\Interfaces\ICustomMailerResolver;
class MyMailTransportResolver implements ICustomMailerResolver
{
function resolve(): \Illuminate\Mail\Transport\Transport
{
return new MyCustomMailTransport();
# You can have multiple mail transport here
# swich(condition){
# case A: return new MyCustomMailTransport1();
# case B: return new MyCustomMailTransport2();
# case C:
# default:
# return new MyCustomMailTransport3();
# }
}
}
namespace App\Providers;
use App\Resolvers\MyMailTransportResolver;
use Crystoline\CustomMailProvider\Interfaces\ICustomMailerResolver;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->app->bind(ICustomMailerResolver::class, MyMailTransportResolver::class );
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.