Search code examples
phpamazon-web-servicesemailamazon-sesaws-php-sdk

How to use AWS SDK for PHP to send email by SES with dedicated IP?


My aws/aws-sdk-php version is 2.7.27. The emails we sent are marked as spam. I found that my AWS account has got 8 dedicated IPs in Dedicated IPs page. But the sender IP of my email isn't any of the dedicated IPs, it's a shared IP of amazon SES. In developer document of SES, I found that they said I can make a Configuration Set to specify whick IP pool is used for sending. I add a param called 'ConfigurationSetName' as the doc said but it doesn't work, my emails are still sending through shared IPs. My code is like:

        $sendingParams = array(
            'Source'               => $fromEmail,
            'Destination'          => array(
                'ToAddresses' => is_array($email) ? $email : array($email),
                //'CcAddresses'  => is_array($ccEmail) ? $ccEmail : array($ccEmail),
                //'BccAddresses' => is_array($bccEmail) ? $bccEmail : array($bccEmail),
            ),
            'Message'              => array(
                // Subject is required
                'Subject' => array(
                    // Data is required
                    'Data'    => $subject,
                    'Charset' => 'utf-8',
                ),
                // Body is required
                'Body'    => array(
                    'Html' => array(
                        // Data is required
                        'Data'    => $content,
                        'Charset' => 'utf-8',
                    ),
                ),
            ),
            'ReplyToAddresses'     => array($fromEmail),
            'ReturnPath'           => $returnPath,
            'ConfigurationSetName' => 'system',
        );
        if (!empty($ccEmail)) {
            $sendingParams['Destination']['CcAddresses'] = is_array($ccEmail) ? $ccEmail : array($ccEmail);
        }
        if (!empty($bccEmail)) {
            $sendingParams['Destination']['BccAddresses'] = is_array($bccEmail) ? $bccEmail : array($bccEmail);
        }
        $result = $this->sdkClient->sendEmail($sendingParams);

What's the problem with my code? Should I change the version of the SDK?


Solution

  • I find the problem. My dedicated IPs are warming up, and I can't use them before they were totally warmed up.