Skip to content

Commit 9173b34

Browse files
committed
Improve smtp variable names
_Rename:_ - `SENDER_EMAIL` -> `SMTP_USERNAME` - `SENDER_PASSWORD` -> `SMTP_PASSWORD` - `SENDER_EMAIL` -> Used as `From` in email Resolves #94
1 parent df192be commit 9173b34

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

server/constants/constants.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ var (
1111
DATABASE_NAME = ""
1212
SMTP_HOST = ""
1313
SMTP_PORT = ""
14+
SMTP_USERNAME = ""
15+
SMTP_PASSWORD = ""
1416
SENDER_EMAIL = ""
15-
SENDER_PASSWORD = ""
1617
JWT_TYPE = ""
1718
JWT_SECRET = ""
1819
ALLOWED_ORIGINS = []string{}

server/email/email.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ type Sender struct {
2727
}
2828

2929
func NewSender() Sender {
30-
return Sender{User: constants.SENDER_EMAIL, Password: constants.SENDER_PASSWORD}
30+
return Sender{User: constants.SMTP_USERNAME, Password: constants.SMTP_PASSWORD}
3131
}
3232

3333
func (sender Sender) SendMail(Dest []string, Subject, bodyMessage string) error {
34-
msg := "From: " + sender.User + "\n" +
34+
msg := "From: " + constants.SENDER_EMAIL + "\n" +
3535
"To: " + strings.Join(Dest, ",") + "\n" +
3636
"Subject: " + Subject + "\n" + bodyMessage
3737

server/env/env.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,16 @@ func InitEnv() {
9494
constants.SMTP_PORT = os.Getenv("SMTP_PORT")
9595
}
9696

97-
if constants.SENDER_EMAIL == "" {
98-
constants.SENDER_EMAIL = os.Getenv("SENDER_EMAIL")
97+
if constants.SMTP_USERNAME == "" {
98+
constants.SMTP_USERNAME = os.Getenv("SMTP_USERNAME")
99+
}
100+
101+
if constants.SMTP_PASSWORD == "" {
102+
constants.SMTP_PASSWORD = os.Getenv("SMTP_PASSWORD")
99103
}
100104

101-
if constants.SENDER_PASSWORD == "" {
102-
constants.SENDER_PASSWORD = os.Getenv("SENDER_PASSWORD")
105+
if constants.SENDER_EMAIL == "" {
106+
constants.SENDER_EMAIL = os.Getenv("SENDER_EMAIL")
103107
}
104108

105109
if constants.JWT_SECRET == "" {
@@ -174,7 +178,7 @@ func InitEnv() {
174178
constants.DISABLE_MAGIC_LINK_LOGIN = os.Getenv("DISABLE_MAGIC_LINK_LOGIN") == "true"
175179
constants.DISABLE_LOGIN_PAGE = os.Getenv("DISABLE_LOGIN_PAGE") == "true"
176180

177-
if constants.SMTP_HOST == "" || constants.SENDER_EMAIL == "" || constants.SENDER_PASSWORD == "" {
181+
if constants.SMTP_HOST == "" || constants.SMTP_USERNAME == "" || constants.SMTP_PASSWORD == "" || constants.SENDER_EMAIL == "" {
178182
constants.DISABLE_EMAIL_VERIFICATION = true
179183
constants.DISABLE_MAGIC_LINK_LOGIN = true
180184
}

0 commit comments

Comments
 (0)