Skip to content

Commit f2fe584

Browse files
committed
feat: add support for SMTP LocalName
Resolves #274
1 parent 287b952 commit f2fe584

File tree

14 files changed

+123
-14
lines changed

14 files changed

+123
-14
lines changed

dashboard/src/components/EnvComponents/EmailConfiguration.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,26 @@ const EmailConfigurations = ({
4848
/>
4949
</Center>
5050
</Flex>
51+
<Flex direction={isNotSmallerScreen ? 'row' : 'column'}>
52+
<Flex
53+
w={isNotSmallerScreen ? '30%' : '40%'}
54+
justifyContent="start"
55+
alignItems="center"
56+
>
57+
<Text fontSize="sm">SMTP Local Name:</Text>
58+
</Flex>
59+
<Center
60+
w={isNotSmallerScreen ? '70%' : '100%'}
61+
mt={isNotSmallerScreen ? '0' : '3'}
62+
>
63+
<InputField
64+
borderRadius={5}
65+
variables={variables}
66+
setVariables={setVariables}
67+
inputType={TextInputType.SMTP_LOCAL_NAME}
68+
/>
69+
</Center>
70+
</Flex>
5171
<Flex direction={isNotSmallerScreen ? 'row' : 'column'}>
5272
<Flex
5373
w={isNotSmallerScreen ? '30%' : '40%'}

dashboard/src/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const TextInputType = {
1515
SMTP_HOST: 'SMTP_HOST',
1616
SMTP_PORT: 'SMTP_PORT',
1717
SMTP_USERNAME: 'SMTP_USERNAME',
18+
SMTP_LOCAL_NAME: 'SMTP_LOCAL_NAME',
1819
SENDER_EMAIL: 'SENDER_EMAIL',
1920
ORGANIZATION_NAME: 'ORGANIZATION_NAME',
2021
ORGANIZATION_LOGO: 'ORGANIZATION_LOGO',
@@ -129,6 +130,7 @@ export interface envVarTypes {
129130
SMTP_PORT: string;
130131
SMTP_USERNAME: string;
131132
SMTP_PASSWORD: string;
133+
SMTP_LOCAL_NAME: string;
132134
SENDER_EMAIL: string;
133135
ALLOWED_ORIGINS: [string] | [];
134136
ORGANIZATION_NAME: string;

dashboard/src/graphql/queries/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export const EnvVariablesQuery = `
4545
SMTP_PORT
4646
SMTP_USERNAME
4747
SMTP_PASSWORD
48+
SMTP_LOCAL_NAME
4849
SENDER_EMAIL
4950
ALLOWED_ORIGINS
5051
ORGANIZATION_NAME

dashboard/src/pages/Environment.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ const Environment = () => {
6565
SMTP_PORT: '',
6666
SMTP_USERNAME: '',
6767
SMTP_PASSWORD: '',
68+
SMTP_LOCAL_NAME: '',
6869
SENDER_EMAIL: '',
6970
ALLOWED_ORIGINS: [],
7071
ORGANIZATION_NAME: '',

server/constants/env.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ const (
5151
EnvKeySmtpUsername = "SMTP_USERNAME"
5252
// EnvKeySmtpPassword key for env variable SMTP_PASSWORD
5353
EnvKeySmtpPassword = "SMTP_PASSWORD"
54+
// EnvKeySmtpLocalName key for env variable SMTP_LOCAL_NAME
55+
EnvKeySmtpLocalName = "SMTP_LOCAL_NAME"
5456
// EnvKeySenderEmail key for env variable SENDER_EMAIL
5557
EnvKeySenderEmail = "SENDER_EMAIL"
5658
// EnvKeyIsEmailServiceEnabled key for env variable IS_EMAIL_SERVICE_ENABLED

server/email/email.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"crypto/tls"
77
"strconv"
8+
"strings"
89
"text/template"
910

1011
log "github.com/sirupsen/logrus"
@@ -126,6 +127,12 @@ func SendEmail(to []string, event string, data map[string]interface{}) error {
126127
return err
127128
}
128129

130+
smtpLocalName, err := memorystore.Provider.GetStringStoreEnvVariable(constants.EnvKeySmtpLocalName)
131+
if err != nil {
132+
log.Debugf("Error while getting smtp localname from env variable: %v", err)
133+
smtpLocalName = ""
134+
}
135+
129136
isProd, err := memorystore.Provider.GetBoolStoreEnvVariable(constants.EnvKeyIsProd)
130137
if err != nil {
131138
log.Errorf("Error while getting env variable: %v", err)
@@ -141,6 +148,11 @@ func SendEmail(to []string, event string, data map[string]interface{}) error {
141148
if !isProd {
142149
d.TLSConfig = &tls.Config{InsecureSkipVerify: true}
143150
}
151+
152+
if strings.TrimSpace(smtpLocalName) != "" {
153+
d.LocalName = smtpLocalName
154+
}
155+
144156
if err := d.DialAndSend(m); err != nil {
145157
log.Debug("SMTP Failed: ", err)
146158
return err

server/env/env.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func InitAllEnv() error {
5555
osSmtpPort := os.Getenv(constants.EnvKeySmtpPort)
5656
osSmtpUsername := os.Getenv(constants.EnvKeySmtpUsername)
5757
osSmtpPassword := os.Getenv(constants.EnvKeySmtpPassword)
58+
osSmtpLocalName := os.Getenv(constants.EnvKeySmtpLocalName)
5859
osSenderEmail := os.Getenv(constants.EnvKeySenderEmail)
5960
osJwtType := os.Getenv(constants.EnvKeyJwtType)
6061
osJwtSecret := os.Getenv(constants.EnvKeyJwtSecret)
@@ -205,6 +206,13 @@ func InitAllEnv() error {
205206
envData[constants.EnvKeySmtpUsername] = osSmtpUsername
206207
}
207208

209+
if val, ok := envData[constants.EnvKeySmtpLocalName]; !ok || val == "" {
210+
envData[constants.EnvKeySmtpLocalName] = osSmtpLocalName
211+
}
212+
if osSmtpLocalName != "" && envData[constants.EnvKeySmtpLocalName] != osSmtpLocalName {
213+
envData[constants.EnvKeySmtpLocalName] = osSmtpLocalName
214+
}
215+
208216
if val, ok := envData[constants.EnvKeySmtpPassword]; !ok || val == "" {
209217
envData[constants.EnvKeySmtpPassword] = osSmtpPassword
210218
}

server/go.sum

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk=
123123
github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
124124
github.com/gocql/gocql v1.2.0 h1:TZhsCd7fRuye4VyHr3WCvWwIQaZUmjsqnSIXK9FcVCE=
125125
github.com/gocql/gocql v1.2.0/go.mod h1:3gM2c4D3AnkISwBxGnMMsS8Oy4y2lhbPRsH4xnJrHG8=
126-
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
127126
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
128127
github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0=
129128
github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
@@ -258,6 +257,7 @@ github.com/jinzhu/now v1.1.3 h1:PlHq1bSCSZL9K0wUhbm2pGLoTWs2GwVhsP6emvGV/ZI=
258257
github.com/jinzhu/now v1.1.3/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
259258
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
260259
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
260+
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
261261
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
262262
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
263263
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
@@ -492,12 +492,11 @@ golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwY
492492
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
493493
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
494494
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
495+
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
496+
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
495497
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
496498
golang.org/x/net v0.0.0-20220930213112-107f3e3c3b0b h1:uKO3Js8lXGjpjdc4J3rqs0/Ex5yDKUGfk43tTYWVLas=
497499
golang.org/x/net v0.0.0-20220930213112-107f3e3c3b0b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
498-
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
499-
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk=
500-
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
501500
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
502501
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
503502
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -561,14 +560,13 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
561560
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
562561
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
563562
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
563+
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
564564
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
565565
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
566566
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
567567
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
568568
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec h1:BkDtF2Ih9xZ7le9ndzTA7KJow28VbQW3odyk/8drmuI=
569569
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
570-
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
571-
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
572570
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
573571
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
574572
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=

server/graph/generated/generated.go

Lines changed: 66 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/graph/model/models_gen.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)