PHP code example of anikninja / mail-mapper

1. Go to this page and download the library: Download anikninja/mail-mapper 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/ */

    

anikninja / mail-mapper example snippets


return [
    'default_from'  => [
            'address'   => env('MAIL_FROM_ADDRESS', '[email protected]'),
            'name'      => env('MAIL_FROM_NAME', 'No Reply'),
    ],
    'use_raw_fallback'  => env('MAIL_MAPPER_USE_RAW_FALLBACK', true),
    'enable_logging'    => env('MAIL_MAPPER_ENABLE_LOGGING', true),
    'user_model'        => config('auth.providers.users.model', \App\Models\User::class), // Change default as needed
];

'authorization' => [
    'roles' => ['admin','super-admin'],
    'permissions' => ['email-mapping-configure'],
    'allow_super_admin' => true,
    'default_allow' => false,
],

use AnikNinja\MailMapper\Traits\NotifiesByEmailMapping;

class LeadController extends Controller
{
    use NotifiesByEmailMapping;

    public function store(Request $request)
    {
        // Business logic...

        $this->notifyByMapping(
            module: 'Sales',
            menu: 'Lead Generation',
            task: 'Create',
            modelOrContext: $lead, // Lead Model Object or associative array providing context for placeholders.
            extra: [
                'custom_note' => 'Urgent lead created'
            ],
            useRaw: false
        );
    }
}

send_mail_mapping(
    'Sales',
    'Lead Generation',
    'Update',
    [
        'customer_name' => 'Customer 1',
        'customer_address' => 'Customer Address 1'
    ]
);

['attachments' => [
    [
        'filename' => 'file.pdf',
        'content' => file_get_contents($path),
        'mime' => 'application/pdf',
    ],
]]

['attachments' => ['/full/path/to/file.pdf']]

['attachments' => [$request->file('upload')]]

$this->notifyByMapping(
    'Sales',
    'Leads',
    'Create',
    $model,
    ['attachments' => ['/path/to/invoice.pdf']]
);

SendEmailNotificationJob::dispatch([
    'to' => ['[email protected]'],
    'subject' => 'System Update',
    'body' => '<p>Update completed</p>',
    'use_raw' => true,
]);
bash
php artisan vendor:publish --provider="AnikNinja\MailMapper\MailMapperServiceProvider"
bash
php artisan migrate
arduino
config/mail-mapper.php
swift
resources/views/mail/dynamic_notification.blade.php
bash
php artisan vendor:publish --tag=views
bash
php artisan queue:work