AWS_SES_WP_Mail\SES::get_instance PHP Method

get_instance() public static method

public static get_instance ( ) : SES
return SES
    public static function get_instance()
    {
        if (!self::$instance) {
            $key = defined('AWS_SES_WP_MAIL_KEY') ? AWS_SES_WP_MAIL_KEY : null;
            $secret = defined('AWS_SES_WP_MAIL_SECRET') ? AWS_SES_WP_MAIL_SECRET : null;
            $region = defined('AWS_SES_WP_MAIL_REGION') ? AWS_SES_WP_MAIL_REGION : null;
            self::$instance = new static($key, $secret, $region);
        }
        return self::$instance;
    }

Usage Example

 protected function get_sending_domain_dns_records($domain)
 {
     $ses = SES::get_instance()->get_client();
     if (is_wp_error($ses)) {
         WP_CLI::error($ses->get_error_code() . ': ' . $ses->get_error_message());
     }
     try {
         $verify = $ses->verifyDomainIdentity(array('Domain' => $domain));
     } catch (\Exception $e) {
         WP_CLI::error(get_class($e) . ': ' . $e->getMessage());
     }
     $dkim = $ses->verifyDomainDkim(array('Domain' => $domain));
     $dns_records[] = array('Domain' => '_amazonses.' . $domain, 'Type' => 'TXT', 'Value' => $verify['VerificationToken']);
     foreach ($dkim['DkimTokens'] as $token) {
         $dns_records[] = array('Domain' => $token . '._domainkey.' . $domain, 'Type' => 'CNAME', 'Value' => $token . '.dkim.amazonses.com');
     }
     return $dns_records;
 }