

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# Amazon SES API および AWS SDK for PHP バージョン 3 を使用した E メールアイデンティティの検証
<a name="ses-verify"></a>

初めて Amazon Simple Email Service (Amazon SES) アカウントを使用し始めるとき、E メールの送信先となる同じ AWS リージョン内のすべての送信者と受取人を確認する必要があります。E メール送信の詳細については、「[Amazon SES を使用してメールを送信する](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-email.html)」を参照してください。

以下の例では、次の方法を示しています。
+ [VerifyEmailIdentity](https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-email-2010-12-01.html#verifyemailidentity) を使用して E メールアドレスを確認する。
+ [VerifyDomainIdentity](https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-email-2010-12-01.html#verifydomainidentity) を使用して E メールドメインを確認する。
+ [ListIdentities](https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-email-2010-12-01.html#listidentities) を使用して E メールアドレスをリストする。
+ [ListIdentities](https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-email-2010-12-01.html#listidentities) を使用して E メールドメインをリストする。
+ [DeleteIdentity](https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-email-2010-12-01.html#deleteidentity) を使用して E メールアドレスを削除する。
+ [DeleteIdentity](https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-email-2010-12-01.html#deleteidentity) を使用して E メールドメインを削除する。

AWS SDK for PHP 用のすべてのサンプルコードは [GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/php/example_code) で入手できます。

## 認証情報
<a name="examplecredentials"></a>

サンプルコードを実行する前に、AWS の認証情報を設定します ([AWS SDK for PHP バージョン 3 AWS を使用した での認証](credentials.md) を参照)。AWS SDK for PHP からのインポート ([AWS SDK for PHP バージョン 3 のインストール](getting-started_installation.md) を参照)。

Amazon SES の使用の詳細については、「[Amazon SES デベロッパーガイド](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/)」を参照してください。

## E メールアドレスを検証する
<a name="verifying-email-addresses"></a>

Amazon SES は、確認済み E メールアドレスまたはドメインからのみ E メールを送信できます。E メールアドレスを確認することで、そのアドレスの所有者であることを示し、そのアドレスから E メールを送信することを Amazon SES に許可します。

以下のコード例を実行すると、指定したアドレスに Amazon SES により E メールが送信されます。お客様 (または E メールの受取人) が E メール内のリンクをクリックすると、アドレスが確認されます。

Amazon SES アカウントに E メールアドレスを追加するには、[VerifyEmailIdentity](https://docs.aws.amazon.com/ses/latest/APIReference/API_VerifyEmailIdentity.html) オペレーションを使用します。

 **インポート**。

```
require 'vendor/autoload.php';

use Aws\Exception\AwsException;
```

 **サンプルコード** 

```
$SesClient = new Aws\Ses\SesClient([
    'profile' => 'default',
    'version' => '2010-12-01',
    'region' => 'us-east-2'
]);

$email = 'email_address';

try {
    $result = $SesClient->verifyEmailIdentity([
        'EmailAddress' => $email,
    ]);
    var_dump($result);
} catch (AwsException $e) {
    // output error message if fails
    echo $e->getMessage();
    echo "\n";
}
```

## E メールドメインを検証する
<a name="verify-an-email-domain"></a>

Amazon SES は、確認済み E メールアドレスまたはドメインからのみ E メールを送信できます。ドメインを確認することで、そのドメインの所有者であることを示します。ドメインを検証すると、そのドメインの任意のアドレスからの E メールの送信を Amazon SES に許可します。

以下のコード例を実行すると、Amazon SES により検証トークンが提供されます。ドメインの DNS 設定にトークンを追加する必要があります。詳細については、「Amazon Simple Email Service デベロッパーガイド」の「[Amazon SES でのドメインの検証](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-domain-procedure.html)」を参照してください。

Amazon SES アカウントに送信側ドメインを追加するには、[VerifyDomainIdentity](https://docs.aws.amazon.com/ses/latest/APIReference/API_VerifyDomainIdentity.html) オペレーションを使用します。

 **インポート**。

```
require 'vendor/autoload.php';

use Aws\Exception\AwsException;
```

 **サンプルコード** 

```
$SesClient = new Aws\Ses\SesClient([
    'profile' => 'default',
    'version' => '2010-12-01',
    'region' => 'us-east-2'
]);

$domain = 'domain.name';

try {
    $result = $SesClient->verifyDomainIdentity([
        'Domain' => $domain,
    ]);
    var_dump($result);
} catch (AwsException $e) {
    // output error message if fails
    echo $e->getMessage();
    echo "\n";
}
```

## E メールアドレスをリストする
<a name="list-email-addresses"></a>

検証ステータスに関係なく、現在の AWS リージョンで送信された E メールアドレスのリストを取得するには、[ListIdentities](https://docs.aws.amazon.com/ses/latest/APIReference/API_ListIdentities.html) オペレーションを使用します。

 **インポート**。

```
require 'vendor/autoload.php';

use Aws\Exception\AwsException;
```

 **サンプルコード** 

```
$SesClient = new Aws\Ses\SesClient([
    'profile' => 'default',
    'version' => '2010-12-01',
    'region' => 'us-east-2'
]);

try {
    $result = $SesClient->listIdentities([
        'IdentityType' => 'EmailAddress',
    ]);
    var_dump($result);
} catch (AwsException $e) {
    // output error message if fails
    echo $e->getMessage();
    echo "\n";
}
```

## E メールドメインをリストする
<a name="list-email-domains"></a>

検証ステータスに関係なく、現在の AWS リージョンで送信された E メールドメインのリストを取得するには、[ListIdentities](https://docs.aws.amazon.com/ses/latest/APIReference/API_ListIdentities.html) オペレーションを使用します。

 **インポート**。

```
require 'vendor/autoload.php';

use Aws\Exception\AwsException;
```

 **サンプルコード** 

```
$SesClient = new Aws\Ses\SesClient([
    'profile' => 'default',
    'version' => '2010-12-01',
    'region' => 'us-east-2'
]);

try {
    $result = $SesClient->listIdentities([
        'IdentityType' => 'Domain',
    ]);
    var_dump($result);
} catch (AwsException $e) {
    // output error message if fails
    echo $e->getMessage();
    echo "\n";
}
```

## E メールアドレスを削除する
<a name="delete-an-email-address"></a>

ID のリストから確認済み E メールアドレスを削除するには、[DeleteIdentity](https://docs.aws.amazon.com/ses/latest/APIReference/API_DeleteIdentity.html) オペレーションを使用します。

 **インポート**。

```
require 'vendor/autoload.php';

use Aws\Exception\AwsException;
```

 **サンプルコード** 

```
$SesClient = new Aws\Ses\SesClient([
    'profile' => 'default',
    'version' => '2010-12-01',
    'region' => 'us-east-2'
]);

$email = 'email_address';

try {
    $result = $SesClient->deleteIdentity([
        'Identity' => $email,
    ]);
    var_dump($result);
} catch (AwsException $e) {
    // output error message if fails
    echo $e->getMessage();
    echo "\n";
}
```

## E メールドメインを削除する
<a name="delete-an-email-domain"></a>

確認済み ID のリストから確認済み E メールドメインを削除するには、[DeleteIdentity](https://docs.aws.amazon.com/ses/latest/APIReference/API_DeleteIdentity.html) オペレーションを使用します。

 **インポート**。

```
require 'vendor/autoload.php';

use Aws\Exception\AwsException;
```

 **サンプルコード** 

```
$SesClient = new Aws\Ses\SesClient([
    'profile' => 'default',
    'version' => '2010-12-01',
    'region' => 'us-east-2'
]);

$domain = 'domain.name';

try {
    $result = $SesClient->deleteIdentity([
        'Identity' => $domain,
    ]);
    var_dump($result);
} catch (AwsException $e) {
    // output error message if fails
    echo $e->getMessage();
    echo "\n";
}
```