Skip to content

Commit ef76e70

Browse files
committed
Removed hardcoded SMTP server values; Fixed .env-sample; README.md example fix
1 parent de105d5 commit ef76e70

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

.env-sample

+4-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
PGPASSWORD="PASSWORD_GOES_HERE"
1+
export PGPASSWORD="PASSWORD_GOES_HERE"
2+
export SMTP_SERVER="localhost:1025"
3+
export SMTP_LOGIN=""
4+
export SMTP_PASSWORD=""

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
## Dev
44

5-
Used https://mailcatcher.me/ for SMTP testing
6-
7-
Important note: There are a bunch of hardcoded values at the moment.
5+
Use https://mailcatcher.me/ for local SMTP testing.
86

97

108
## Server Setup
@@ -41,7 +39,7 @@ source .env # Sets 'PGPASSWORD' environment variable so pursuemail can use it
4139
### Map Email Address to (Random) UUID
4240

4341
```
44-
curl -i localhost:9080/api/v1/email -d {"email": "spam@pursuanceproject.org"}
42+
curl -i localhost:9080/api/v1/email -d '{"email": "spam@pursuanceproject.org"}'
4543
```
4644

4745

main.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"database/sql"
5+
"net/smtp"
56
"os"
67
"strings"
78

@@ -26,7 +27,9 @@ func main() {
2627
defer db.Close()
2728

2829
// TODO - Setup configuration for Mailgun or similar
29-
emailPool, err := emailLib.NewPool("localhost:1025", 5, nil)
30+
emailPool, err := emailLib.NewPool(os.Getenv("SMTP_SERVER"), 5,
31+
smtp.PlainAuth("", os.Getenv("SMTP_LOGIN"),
32+
os.Getenv("SMTP_PASSWORD"), strings.SplitN(os.Getenv("SMTP_SERVER"), ":", 2)[0]))
3033
if err != nil {
3134
log.Fatalf("Error from email.NewPool: %v", err)
3235
}

0 commit comments

Comments
 (0)