Skip to content

Instantly share code, notes, and snippets.

@jakubboucek
Last active May 2, 2018 08:15
Show Gist options
  • Save jakubboucek/c33f169dc33899d41b4534c73f1161c4 to your computer and use it in GitHub Desktop.
Save jakubboucek/c33f169dc33899d41b4534c73f1161c4 to your computer and use it in GitHub Desktop.
Convert AWS IAM credentials to SMTP credentials
<?php
if (!isset($argv[1])) {
echo 'You must key as command\'s parameter' . PHP_EOL;
die(1);
}
// by https://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html
$awsSecretAccessKey = $argv[1];
$version = "\x02";
$hash = hash_hmac('sha256', 'SendRawEmail', $awsSecretAccessKey, true);
$smtpPassword = base64_encode($version . $hash);
echo $smtpPassword . PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment