humanmade / aws-ses-wp-mail

An AWS SES wp_mail() drop-in
186 stars 51 forks source link

Fails to use key & secret on local dev environment #12

Closed roborourke closed 7 years ago

roborourke commented 8 years ago

Simply specifying the key & secret doesn't work on a local dev environment. You have to either:

a) Have a credentials file in the web server users home directory .aws/credentials

b) Pass a credentials object in the params:

$params['credentials'] => array(
  'key' => $this->key,
  'secret' => $this->secret,
  'token' => '' // Need to fetch a token to use email service, via StsClient
);

Question is do we add code to fetch the token or rely solely on the credentials file approach? Right now the defines don't do anything.

joehoyle commented 8 years ago

Doh, my bad I think!

roborourke commented 8 years ago

@joehoyle no worries! Super easy to miss, I was digging through the SDK for a while to find out what it was doing! I have the AWS CLI on my laptop rather than the VM so probably why I hit this problem. What do you think re. fetching the token? I can put some time into it.

joehoyle commented 8 years ago

Hmm this is the first I've heard about this token, this isn't required for other AWS Services, is this something SES specific?

roborourke commented 8 years ago

I think so. It's the first time I've come across it too. I may be missing something but just going off what the error messages say. You should be able to reproduce it by moving your ~/.aws folder temporarily and adding the key & secret & region constants

BrookeDot commented 7 years ago

I just ran into this today when installing this plugin for the first time in production. I went with option B (but didn't need the token) to get the creds to verify. Found the answer on StackOverflow then came here. I changed line 178 of inc/class-ses.php to read:

          if ( $this->key && $this->secret ) {
                $params['credentials']['key'] = $this->key;
                $params['credentials']['secret'] = $this->secret;
                }