1. Go to this page and download the library: Download ankitfromindia/mx18-laravel 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/ */
ankitfromindia / mx18-laravel example snippets
use AnkitFromIndia\MX18\Mail\MX18Mail;
use AnkitFromIndia\MX18\Facades\MX18;
$mail = (new MX18Mail())
->from('[email protected]', 'Your Name')
->to('[email protected]', 'Recipient Name')
->subject('Welcome to Our Service')
->html('<h1>Hello {{name}}!</h1><p>Welcome to our platform.</p>')
->text('Hello {{name}}! Welcome to our platform.');
$response = MX18::send($mail);
$mail = (new MX18Mail())
->from('[email protected]', 'Your Company')
->to('[email protected]', 'John Doe', ['name' => 'John', 'plan' => 'Premium'])
->cc('[email protected]', 'Manager')
->replyTo('[email protected]', 'Support Team')
->subject('Your {{plan}} account is ready!')
->html('<h1>Hi {{name}}</h1><p>Your {{plan}} plan is now active.</p>')
->globalPersonalization(['company' => 'Your Company']);
$response = MX18::send($mail);
// In EventServiceProvider.php
use AnkitFromIndia\MX18\Webhooks\WebhookReceived;
protected $listen = [
WebhookReceived::class => [
'App\Listeners\HandleMX18Webhook',
],
];
// app/Listeners/HandleMX18Webhook.php
namespace App\Listeners;
use AnkitFromIndia\MX18\Webhooks\WebhookReceived;
class HandleMX18Webhook
{
public function handle(WebhookReceived $event)
{
$payload = $event->payload;
// Handle different event types
switch ($payload['event']) {
case 'delivered':
// Email was delivered
break;
case 'opened':
// Email was opened
break;
case 'clicked':
// Link was clicked
break;
case 'bounced':
// Email bounced
break;
}
}
}
[
'transactionId' => 'abc123xyz456',
'status' => 'Accepted',
'message' => 'Email request has been accepted for delivery.'
]