PHP code example of bnomei / kirby-resend

1. Go to this page and download the library: Download bnomei/kirby-resend 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/ */

    

bnomei / kirby-resend example snippets




// regular "transactional" email
$to = '[email protected]';

$success = kirby()->email([
    'from' => new \Kirby\Cms\User([
        'email' => '[email protected]', // your verified resend sender
        'name' => 'Example Name', // your name
    ]),
    'to' => $to,
    'subject' => 'Sending E-Mails is fun',
    'body' => [
        'html' => '<h1>Headline</h1><p>Text</p>',
        'text' => "Headline\n\nText",
    ],
    'transport' => resend()->transport(), // plugin helper to get SMTP config array
])->isSent();

$client = resend()->client();
$sendResult = $client->emails->send([
    'from' => '[email protected]',
    'to' => '[email protected]',
    'subject' => 'Hello World',
    'html' => '<strong>it works!</strong>',
]);

// Getting the ID from the response Email object
// https://github.com/resendlabs/resend-php/blob/main/src/Email.php
echo $sendResult->id;

return [
    // …other settings
    'auth' => [
        'methods' => ['password', 'password-reset'],
        'challenge' => [
            'email' => [
                'from'     => '[email protected]', // your verified postmark sender
                'fromName' => 'Example Name',
            ]
        ]
    ],
    'email' => [
        'transport' => [
            'type' => 'smtp',
            'host' => 'smtp.resend.com',
            'port' => 587,
            'security' => true,
            'auth' => true,
            'username' => 'resend', // needs to be 'resend'
            'password' => 'YOUR-APIKEY-HERE', // your resend apikey
        ]
    ]
];

return [
    // other config settings ...
    'bnomei.resend.apikey' => 'YOUR-APIKEY-HERE',
];

return [
    // other config settings ...
    'bnomei.resend.apikey' => function() { return env('RESEND_APIKEY_TOKEN'); },
];