PHP code example of getodden / ses-tenants

1. Go to this page and download the library: Download getodden/ses-tenants 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/ */

    

getodden / ses-tenants example snippets


use Odden\SesTenants\Contracts\SesOwner;

class Team extends Model implements SesOwner
{
    public function sesTenantName(): string { return "team-{$this->id}"; }

    public function sesIsRisky(): bool { return $this->onTrial(); }
}

$schedule->command('ses-tenants:check-domains')->everyFiveMinutes();
$schedule->command('ses-tenants:sync')->hourly();
$schedule->command('ses-tenants:release-orphans')->daily();

use Odden\SesTenants\Identities\SesIdentities;
use Odden\SesTenants\Dns\DnsRecords;
use Odden\SesTenants\Domains\DomainPolicy;

$domain = app(DomainPolicy::class)->normalize($input)
    ?? throw new RuntimeException(app(DomainPolicy::class)->problem($input));

$identities = app(SesIdentities::class);
$state = $identities->create($domain, "bounce.{$domain}");
$identities->attachToTenant("customer-{$customer->id}", $domain);

$records = DnsRecords::for($domain, $state->dkimTokens, "bounce.{$domain}", config('ses-tenants.region'));
// show $records to the customer; later:
$identities->describe($domain)->isVerified();

config(['mail.mailers.customer' => [
    'transport' => 'ses-tenants',
    'tenant_name' => "customer-{$customer->id}",
    'domains' => $customer->verifiedDomains(),   // exact names
    'owner_id' => $customer->id,
]]);

Mail::mailer('customer')->to($to)->send($mailable);

app(\Odden\SesTenants\Sns\SnsVerifier::class)->verify($request->json()->all()); // throws SnsException