fix(email): rename settings parameter and switch to safe default

This commit is contained in:
Steffen Jost 2022-01-06 14:24:12 +01:00
parent f41e26877b
commit 5aa096f56a
4 changed files with 7 additions and 7 deletions

View File

@ -19,7 +19,7 @@ mail-from:
name: "_env:MAILFROM_NAME:Uni2work"
email: "_env:MAILFROM_EMAIL:uniworx@localhost"
mail-object-domain: "_env:MAILOBJECT_DOMAIN:localhost"
mail-sender-fixed: "_env:MAILSENDER_FIXED:True"
mail-use-replyto-instead-sender: "_env:MAIL_USES_REPLYTO:true"
#mail-verp:
# separator: "_env:VERP_SEPARATOR:+"
# prefix: "_env:VERP_PREFIX:bounce"

View File

@ -177,7 +177,7 @@ instance YesodMail UniWorX where
defaultFromAddress = getsYesod $ view _appMailFrom
envelopeFromAddress = getsYesod $ view _appMailEnvelopeFrom
mailObjectIdDomain = getsYesod $ view _appMailObjectDomain
fixedSenderInDomain = getsYesod $ view _appMailFixedDomainSender
useReplyToInstead = getsYesod $ view _appMailUseReplyToInstead
mailDateTZ = return appTZ
mailSmtp act = do
pool <- maybe (throwM MailNotAvailable) return =<< getsYesod appSmtpPool

View File

@ -257,8 +257,8 @@ class Yesod site => YesodMail site where
mailObjectIdDomain = pack <$> liftIO getHostName
-- | Use replyTo instead for all senders within mailObjectIdDomain
fixedSenderInDomain :: (MonadHandler m, HandlerSite m ~ site) => m Bool
fixedSenderInDomain = return False
useReplyToInstead :: (MonadHandler m, HandlerSite m ~ site) => m Bool
useReplyToInstead = return True -- not changeing the sender is the save choice
mailDateTZ :: (MonadHandler m, HandlerSite m ~ site) => m TZ
mailDateTZ = return utcTZ
@ -316,7 +316,7 @@ defMailT ls (MailT mailC) = do
(ret, mail, smtpData) <- runRWST mailC ls (emptyMail fromAddress)
mail' <- maybeT (return mail) $ do
guardM fixedSenderInDomain -- if sender must be fixed within ObjectIdDomain, use replyTo instead
guardM useReplyToInstead -- if sender must be fixed within ObjectIdDomain, use replyTo instead
let sender = mail ^. _mailFrom
domain <- lift mailObjectIdDomain
guard $ domain `Text.isSuffixOf` (sender ^. _addressEmail) -- allowing foreign senders might be Fraport specific; maybe remove this guard

View File

@ -126,7 +126,7 @@ data AppSettings = AppSettings
, appMailFrom
, appMailSender
, appMailSupport :: Address
, appMailFixedDomainSender :: Bool
, appMailUseReplyToInstead :: Bool
, appJobWorkers :: Natural
, appJobFlushInterval :: Maybe NominalDiffTime
, appJobCronInterval :: Maybe NominalDiffTime
@ -558,7 +558,7 @@ instance FromJSON AppSettings where
appMailEnvelopeFrom <- o .:? "mail-envelope-from" .!= addressEmail appMailFrom
appMailSender <- o .:? "mail-sender" .!= appMailFrom
appMailObjectDomain <- o .: "mail-object-domain"
appMailFixedDomainSender <- o .: "mail-sender-fixed" .!= True
appMailUseReplyToInstead <- o .: "mail-use-replyto-instead-sender" .!= True
appMailVerp <- fromMaybe VerpNone . join <$> (o .:? "mail-verp" <|> pure Nothing)
appMailRetainSent <- o .: "mail-retain-sent"