Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signature V4 not working? #72

Open
jane-t opened this issue Jul 21, 2020 · 11 comments
Open

Signature V4 not working? #72

jane-t opened this issue Jul 21, 2020 · 11 comments

Comments

@jane-t
Copy link

jane-t commented Jul 21, 2020

Sorry to trouble you. I have downloaded the latest version using composer.

The following code appears to work eg no errors, but the email never arrives.
`$signature_version = SimpleEmailService::REQUEST_SIGNATURE_V4;
$region_endpoint = SimpleEmailService::AWS_US_EAST_1;
$trigger_error = true;
$ses = new SimpleEmailService('AccessKey', 'SecretKey', $region_endpoint, $trigger_error, $signature_version);

$messagetmpl = file_get_contents('email.txt');
$subject = $str = strtok($messagetmpl, "\n");
$userlist = file('email_list.txt');
foreach ($userlist as $line) {
// Loop Emails
$user = explode(',',$line);

$message = str_replace('{user}',$user[1],$messagetmpl);
$message = str_replace('{password}',$user[2],$message);
$message = str_replace('{signup}',$user[3],$message);
$message = str_replace('{last}',$user[4],$message);

$m = new SimpleEmailServiceMessage();
$m->addTo($user[0]);
$m->setFrom('Admin at xxxxxxx@xxxx.org.uk');
$m->setSubject($subject);
$m->setMessageFromString($message);
echo $user[0].' ',$user[1].'
';

$ses->sendEmail($m);

usleep(200000);
// End Loop Emails
}
echo 'All Done';`

If I change the ses line to just
$ses = new SimpleEmailService($key, $secret);

The email arrives, is there something I need to do in the Amazon Management Console which I have not done?

@daniel-zahariev
Copy link
Owner

Hi @jane-t,
did you check if $ses->sendEmail($m); returns an error when you use v4 signature?
If there's an issue in the AWS console this error might give you a hint.
Have you verified the sender email?

@jane-t
Copy link
Author

jane-t commented Jul 21, 2020

The sender is verified. If I call the ses set up process with
$ses = new SimpleEmailService($key, $secret);

It works fine, it's only when I call it with the V4

I have found the error I am getting

PHP Warning: SimpleEmailService::sendEmail(): Sender - InvalidClientTokenId: The security token included in the request is invalid.

I am not changing the access or secret between the two options.

@daniel-zahariev
Copy link
Owner

Hm, that's weird.
Can't find anything that can lead to this error.

@jane-t
Copy link
Author

jane-t commented Jul 22, 2020 via email

@daniel-zahariev
Copy link
Owner

I'll dig into this tomorrow.
In the mean time - have you tried using different credentials?

@jane-t
Copy link
Author

jane-t commented Jul 23, 2020 via email

@jane-t
Copy link
Author

jane-t commented Aug 4, 2020

Did you have any liuck with this problem please?

@daniel-zahariev
Copy link
Owner

Still can't recreate the issue.

@aa6my
Copy link

aa6my commented Aug 26, 2020

@jane-t its work, but attachment not working in web/cli. you can check #73

@aa6my
Copy link

aa6my commented Aug 26, 2020

@jane-t its work, but attachment not working in web/cli. you can check #73

its work with another method in #73

@vborduja
Copy link

@aa6my @jane-t
It works for me: sendMail() and sendMailRaw()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants