Skip to content

Commit

Permalink
Allow setting AWS credentials via environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickxb committed Mar 11, 2016
1 parent fbd5919 commit 456ebd6
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions amzses.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"log"
"net/http"
"net/url"
"os"
"strings"
"time"

Expand All @@ -31,9 +32,18 @@ const (
var accessKey, secretKey string

func init() {
config := jconfig.LoadConfig("/etc/aws.conf")
accessKey = config.GetString("aws_access_key")
secretKey = config.GetString("aws_secret_key")
accessKey = os.Getenv("AWS_SES_ACCESS_KEY")
secretKey = os.Getenv("AWS_SES_SECRET_KEY")

if accessKey == "" || secretKey == "" {
config := jconfig.LoadConfig("/etc/aws.conf")
if accessKey == "" {
accessKey = config.GetString("aws_access_key")
}
if secretKey == "" {
secretKey = config.GetString("aws_secret_key")
}
}
}

func SendMail(from, to, subject, body string) (string, error) {
Expand Down

0 comments on commit 456ebd6

Please sign in to comment.