add variable SMTP_AUTHENTICATION_ENABLED
* boolean setting whether SMTP authentication is required or not (default: true)
This commit is contained in:
parent
468de54746
commit
09fa59110b
|
@ -13,6 +13,7 @@ env_variables:
|
||||||
TEMPLATE_CONTACT_REQUEST_REPLY: templates/template_reply_contact_request.html
|
TEMPLATE_CONTACT_REQUEST_REPLY: templates/template_reply_contact_request.html
|
||||||
SMTP_SERVER_ADDR: "smtp.mailgun.org:587"
|
SMTP_SERVER_ADDR: "smtp.mailgun.org:587"
|
||||||
SMTP_VERITY_CERT: true
|
SMTP_VERITY_CERT: true
|
||||||
|
SMTP_AUTHENTICATION_ENABLED: true
|
||||||
SMTP_CLIENT_USERNAME: "postmaster@example.com"
|
SMTP_CLIENT_USERNAME: "postmaster@example.com"
|
||||||
SMTP_CLIENT_PASSWORD: "postmasterSecretPassWord"
|
SMTP_CLIENT_PASSWORD: "postmasterSecretPassWord"
|
||||||
CONTACT_REPLY_EMAIL: "noreply@example.com"
|
CONTACT_REPLY_EMAIL: "noreply@example.com"
|
||||||
|
|
|
@ -4,6 +4,7 @@ Regardless of the deployment platform (Google App Engine, Kubernetes, Docker), t
|
||||||
|
|
||||||
* `SMTP_SERVER_ADDR`: Set the address of the SMTP server in the form of `host:port`. It's required that the SMTP server being supporting TLS.
|
* `SMTP_SERVER_ADDR`: Set the address of the SMTP server in the form of `host:port`. It's required that the SMTP server being supporting TLS.
|
||||||
* `SMTP_VERITY_CERT`: Tell whether the SMTP certificate should be validated against top level authorities. If you're using a self-signed certificate on the SMTP server, this value must be set to `false`.
|
* `SMTP_VERITY_CERT`: Tell whether the SMTP certificate should be validated against top level authorities. If you're using a self-signed certificate on the SMTP server, this value must be set to `false`.
|
||||||
|
* `SMTP_AUTHENTICATION_ENABLED`: Boolean (default: `true`) indicating whether SMTP authentication is required or not. If true, the variables `SMTP_CLIENT_USERNAME` and `SMTP_CLIENT_PASSWORD` are used the perform the authentication.
|
||||||
* `SMTP_CLIENT_USERNAME`: Set the username to connect to the SMTP server.
|
* `SMTP_CLIENT_USERNAME`: Set the username to connect to the SMTP server.
|
||||||
* `SMTP_CLIENT_PASSWORD`: Set the password to connect to the SMTP server.
|
* `SMTP_CLIENT_PASSWORD`: Set the password to connect to the SMTP server.
|
||||||
* `CONTACT_REPLY_EMAIL`: Set an email address for the reply email. It's not necessary a valid email address; for example if don't want the user to reply the email, you can set something like `noreply@example.com`.
|
* `CONTACT_REPLY_EMAIL`: Set an email address for the reply email. It's not necessary a valid email address; for example if don't want the user to reply the email, you can set something like `noreply@example.com`.
|
||||||
|
|
1
main.go
1
main.go
|
@ -76,6 +76,7 @@ func main() {
|
||||||
viper.SetDefault("CONTACT_REPLY_BCC_EMAIL", "contact@company.com")
|
viper.SetDefault("CONTACT_REPLY_BCC_EMAIL", "contact@company.com")
|
||||||
viper.SetDefault("EMAIL_SUBJECT", "Thanks to try our product")
|
viper.SetDefault("EMAIL_SUBJECT", "Thanks to try our product")
|
||||||
viper.SetDefault("DEMO_URL", "http://company.com/product-demo")
|
viper.SetDefault("DEMO_URL", "http://company.com/product-demo")
|
||||||
|
viper.SetDefault("SMTP_AUTHENTICATION_ENABLED", true)
|
||||||
|
|
||||||
host := os.Getenv("HOST")
|
host := os.Getenv("HOST")
|
||||||
port := os.Getenv("PORT")
|
port := os.Getenv("PORT")
|
||||||
|
|
|
@ -97,7 +97,7 @@ func (m *SendMailRequest) Execute() error {
|
||||||
defer smtpClient.Quit()
|
defer smtpClient.Quit()
|
||||||
|
|
||||||
// Authenticate if configured
|
// Authenticate if configured
|
||||||
if viper.GetString("SMTP_CLIENT_USERNAME") != "" {
|
if viper.GetBool("SMTP_AUTHENTICATION_ENABLED") {
|
||||||
smtpClientAuth := smtp.PlainAuth("",
|
smtpClientAuth := smtp.PlainAuth("",
|
||||||
viper.GetString("SMTP_CLIENT_USERNAME"),
|
viper.GetString("SMTP_CLIENT_USERNAME"),
|
||||||
viper.GetString("SMTP_CLIENT_PASSWORD"),
|
viper.GetString("SMTP_CLIENT_PASSWORD"),
|
||||||
|
|
Loading…
Reference in New Issue