Skip to content

Instantly share code, notes, and snippets.

@chrisguitarguy
Created April 26, 2018 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisguitarguy/4939ccef7301ba3b269f3100c969165c to your computer and use it in GitHub Desktop.
Save chrisguitarguy/4939ccef7301ba3b269f3100c969165c to your computer and use it in GitHub Desktop.
How to generate AWS SES SMTP passwords from an already existing IAM User secret key. In PHP. See https://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html#smtp-credentials-convert
<?php
$key = getenv('AWS_SECRET_ACCESS_KEY');
if (!$key) {
throw new \LogicException('Missing AWS_SECRET_ACCESS_KEY');
}
$sig = hash_hmac('sha256', 'SendRawEmail', $key, true);
echo base64_encode(pack('C', 0x02) . $sig), PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment