fix(email): rename settings parameter and switch to safe default
This commit is contained in:
parent
f41e26877b
commit
5aa096f56a
@ -19,7 +19,7 @@ mail-from:
|
|||||||
name: "_env:MAILFROM_NAME:Uni2work"
|
name: "_env:MAILFROM_NAME:Uni2work"
|
||||||
email: "_env:MAILFROM_EMAIL:uniworx@localhost"
|
email: "_env:MAILFROM_EMAIL:uniworx@localhost"
|
||||||
mail-object-domain: "_env:MAILOBJECT_DOMAIN: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:
|
#mail-verp:
|
||||||
# separator: "_env:VERP_SEPARATOR:+"
|
# separator: "_env:VERP_SEPARATOR:+"
|
||||||
# prefix: "_env:VERP_PREFIX:bounce"
|
# prefix: "_env:VERP_PREFIX:bounce"
|
||||||
|
|||||||
@ -177,7 +177,7 @@ instance YesodMail UniWorX where
|
|||||||
defaultFromAddress = getsYesod $ view _appMailFrom
|
defaultFromAddress = getsYesod $ view _appMailFrom
|
||||||
envelopeFromAddress = getsYesod $ view _appMailEnvelopeFrom
|
envelopeFromAddress = getsYesod $ view _appMailEnvelopeFrom
|
||||||
mailObjectIdDomain = getsYesod $ view _appMailObjectDomain
|
mailObjectIdDomain = getsYesod $ view _appMailObjectDomain
|
||||||
fixedSenderInDomain = getsYesod $ view _appMailFixedDomainSender
|
useReplyToInstead = getsYesod $ view _appMailUseReplyToInstead
|
||||||
mailDateTZ = return appTZ
|
mailDateTZ = return appTZ
|
||||||
mailSmtp act = do
|
mailSmtp act = do
|
||||||
pool <- maybe (throwM MailNotAvailable) return =<< getsYesod appSmtpPool
|
pool <- maybe (throwM MailNotAvailable) return =<< getsYesod appSmtpPool
|
||||||
|
|||||||
@ -257,8 +257,8 @@ class Yesod site => YesodMail site where
|
|||||||
mailObjectIdDomain = pack <$> liftIO getHostName
|
mailObjectIdDomain = pack <$> liftIO getHostName
|
||||||
|
|
||||||
-- | Use replyTo instead for all senders within mailObjectIdDomain
|
-- | Use replyTo instead for all senders within mailObjectIdDomain
|
||||||
fixedSenderInDomain :: (MonadHandler m, HandlerSite m ~ site) => m Bool
|
useReplyToInstead :: (MonadHandler m, HandlerSite m ~ site) => m Bool
|
||||||
fixedSenderInDomain = return False
|
useReplyToInstead = return True -- not changeing the sender is the save choice
|
||||||
|
|
||||||
mailDateTZ :: (MonadHandler m, HandlerSite m ~ site) => m TZ
|
mailDateTZ :: (MonadHandler m, HandlerSite m ~ site) => m TZ
|
||||||
mailDateTZ = return utcTZ
|
mailDateTZ = return utcTZ
|
||||||
@ -316,7 +316,7 @@ defMailT ls (MailT mailC) = do
|
|||||||
(ret, mail, smtpData) <- runRWST mailC ls (emptyMail fromAddress)
|
(ret, mail, smtpData) <- runRWST mailC ls (emptyMail fromAddress)
|
||||||
|
|
||||||
mail' <- maybeT (return mail) $ do
|
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
|
let sender = mail ^. _mailFrom
|
||||||
domain <- lift mailObjectIdDomain
|
domain <- lift mailObjectIdDomain
|
||||||
guard $ domain `Text.isSuffixOf` (sender ^. _addressEmail) -- allowing foreign senders might be Fraport specific; maybe remove this guard
|
guard $ domain `Text.isSuffixOf` (sender ^. _addressEmail) -- allowing foreign senders might be Fraport specific; maybe remove this guard
|
||||||
|
|||||||
@ -126,7 +126,7 @@ data AppSettings = AppSettings
|
|||||||
, appMailFrom
|
, appMailFrom
|
||||||
, appMailSender
|
, appMailSender
|
||||||
, appMailSupport :: Address
|
, appMailSupport :: Address
|
||||||
, appMailFixedDomainSender :: Bool
|
, appMailUseReplyToInstead :: Bool
|
||||||
, appJobWorkers :: Natural
|
, appJobWorkers :: Natural
|
||||||
, appJobFlushInterval :: Maybe NominalDiffTime
|
, appJobFlushInterval :: Maybe NominalDiffTime
|
||||||
, appJobCronInterval :: Maybe NominalDiffTime
|
, appJobCronInterval :: Maybe NominalDiffTime
|
||||||
@ -558,7 +558,7 @@ instance FromJSON AppSettings where
|
|||||||
appMailEnvelopeFrom <- o .:? "mail-envelope-from" .!= addressEmail appMailFrom
|
appMailEnvelopeFrom <- o .:? "mail-envelope-from" .!= addressEmail appMailFrom
|
||||||
appMailSender <- o .:? "mail-sender" .!= appMailFrom
|
appMailSender <- o .:? "mail-sender" .!= appMailFrom
|
||||||
appMailObjectDomain <- o .: "mail-object-domain"
|
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)
|
appMailVerp <- fromMaybe VerpNone . join <$> (o .:? "mail-verp" <|> pure Nothing)
|
||||||
appMailRetainSent <- o .: "mail-retain-sent"
|
appMailRetainSent <- o .: "mail-retain-sent"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user