diff --git a/.env b/.env index 132f9c97..b97d15ec 100644 --- a/.env +++ b/.env @@ -13,5 +13,6 @@ CAMPUS_API_TOKEN= SMTP_PASSWORD= SMTP_URL= +SMTP_FROM= SMTP_USERNAME= SMTP_PORT= diff --git a/deployment/charts/backend/templates/deployments/backend-v2.yaml b/deployment/charts/backend/templates/deployments/backend-v2.yaml index 6d10351a..bb959aa4 100644 --- a/deployment/charts/backend/templates/deployments/backend-v2.yaml +++ b/deployment/charts/backend/templates/deployments/backend-v2.yaml @@ -70,6 +70,11 @@ spec: secretKeyRef: name: backend-api-keys key: SMTP_URL + - name: SMTP_FROM + valueFrom: + secretKeyRef: + name: backend-api-keys + key: SMTP_FROM - name: SMTP_USERNAME valueFrom: secretKeyRef: @@ -179,6 +184,7 @@ data: APNS_TEAM_ID: {{ $.Values.backend.apns.team_id | b64enc }} SMTP_PASSWORD: {{ $.Values.backend.smtp.password | b64enc }} SMTP_URL: {{ $.Values.backend.smtp.url | b64enc }} + SMTP_FROM: {{ $.Values.backend.smtp.username | b64enc }} SMTP_USERNAME: {{ $.Values.backend.smtp.username | b64enc }} SMTP_PORT: {{ $.Values.backend.smtp.port | b64enc }} --- diff --git a/docker-compose.yaml b/docker-compose.yaml index 4b90d942..b9962328 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -19,7 +19,8 @@ services: - CAMPUS_API_TOKEN=${CAMPUS_API_TOKEN} - SMTP_PASSWORD=${SMTP_PASSWORD} - SMTP_URL=${SMTP_URL:-postout.lrz.de} - - SMTP_USERNAME=${SMTP_USERNAME:-tca-support.os.in@tum.de} + - SMTP_USERNAME=${SMTP_USERNAME:-bot@tum.app} + - SMTP_FROM=${SMTP_FROM:-bot@tum.app} - SMTP_PORT=${SMTP_PORT:-587} volumes: - backend-storage:/Storage diff --git a/server/backend/cron/feedback_email.go b/server/backend/cron/feedback_email.go index ff6841c6..3104d7c0 100644 --- a/server/backend/cron/feedback_email.go +++ b/server/backend/cron/feedback_email.go @@ -56,7 +56,7 @@ type MailHeaders struct { func messageWithHeaders(feedback *model.Feedback) *gomail.Message { m := gomail.NewMessage() // From - m.SetAddressHeader("From", os.Getenv("SMTP_USERNAME"), "TUM Campus App") + m.SetAddressHeader("From", os.Getenv("SMTP_FROM"), "TUM Campus App") // To if feedback.Recipient != "" { m.SetHeader("To", feedback.Recipient) diff --git a/server/backend/cron/feedback_email_test.go b/server/backend/cron/feedback_email_test.go index 1c072c37..34ac9620 100644 --- a/server/backend/cron/feedback_email_test.go +++ b/server/backend/cron/feedback_email_test.go @@ -53,9 +53,10 @@ func emptyFeedback() *model.Feedback { func TestHeaderInstantiationWithFullFeedback(t *testing.T) { require.NoError(t, os.Setenv("SMTP_USERNAME", "outgoing@example.de")) + require.NoError(t, os.Setenv("SMTP_FROM", "from@example.de")) fb := fullFeedback() m := messageWithHeaders(fb) - assert.Equal(t, []string{`"TUM Campus App" `}, m.GetHeader("From")) + assert.Equal(t, []string{`"TUM Campus App" `}, m.GetHeader("From")) assert.Equal(t, []string{fb.Recipient}, m.GetHeader("To")) assert.Equal(t, []string{"test@example.de"}, m.GetHeader("Reply-To")) assert.Equal(t, []string{fb.Timestamp.Time.Format(time.RFC1123Z)}, m.GetHeader("Date")) @@ -64,8 +65,9 @@ func TestHeaderInstantiationWithFullFeedback(t *testing.T) { func TestHeaderInstantiationWithEmptyFeedback(t *testing.T) { require.NoError(t, os.Setenv("SMTP_USERNAME", "outgoing@example.de")) + require.NoError(t, os.Setenv("SMTP_FROM", "from@example.de")) m := messageWithHeaders(emptyFeedback()) - assert.Equal(t, []string{`"TUM Campus App" `}, m.GetHeader("From")) + assert.Equal(t, []string{`"TUM Campus App" `}, m.GetHeader("From")) assert.Equal(t, []string{"app@tum.de"}, m.GetHeader("To")) assert.Equal(t, []string(nil), m.GetHeader("Reply-To")) // Date is set to now in messageWithHeaders => checking that this is actually now is a bit tricker