DevStarlight
DevStarlight

Reputation: 804

sending emails aws-php-sdk v3

I'm trying to integrate and send emails with AWS SES service but for any reason I'm receiving an internal server error.

Here bellow I paste the code I'm using:

User controller

<?php

class User extends Controller
{        
    public function subscribe()
    {
         $ses = $this->model('modelSES');
    }
}

?>

Extending class

<?php 

class Controller
{
    public function model($model, $connection = '')
    {
        require_once '../project/models/' . $model . '.php';

        $db_err = 'http://' . HOST . '/error/database';

        return new $model($connection, $db_err);
    }
}

?>

Model modelSES

<?php

use Aws\Ses\SesClient;

class modelSES
{
    protected $ses;

    public function __construct()
    {
        require '../project/libs/vendor/autoload.php';

        $this->ses = new SesClient([
            'key' => 'XXXXXXXXXXXXXX',
            'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
            'region' => 'us-west-2',
            'version' => '2010-12-01'
        ]);
    }
}

?>

I also configured SES for the verified sender email:

To install the AWS SDK, I followed the AWS-PHP-SDK Guide.

The PHP version i'm using is 5.5.6.

Sounds like the problem rounds when I create the object $this->ses = new SesClient but I don't find the way to connect it properly.

P.S Is HTTPS required?

Upvotes: 0

Views: 684

Answers (1)

totas
totas

Reputation: 10790

What I'm doing to send mails through SES in php is simply use the SMTP Interface from AWS SES. You'll need to obtain SMTP credentials as described here: http://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html

And then you can just send via SMTP.

Upvotes: 1

Related Questions