definition:
|
sendMailWithOptions :: String -> String -> [MailOption] -> String -> IO ()
sendMailWithOptions from subject options contents = do
mailcmdexists <- fileInPath "mailx"
if mailcmdexists
then
-- if mailx has the option -r:
--execMailCmd ("mailx -n -r \"" ++ from ++ "\" -s \"" ++ subject++"\" "++
-- if mailx has the option -a:
execMailCmd "mailx"
(["-n", "-a", "From: " ++ from, "-s", subject] ++ ccs ++ bccs ++ tos)
contents
else error "Command 'mailx' not found in path!"
where
tos = [ s | TO s <- options ]
ccs = concatMap (\m -> ["-a", "Cc: " ++ m]) [ s | CC s <- options ]
bccs = concatMap (\m -> ["-a", "Bcc: " ++ m]) [ s | BCC s <- options ]
|
documentation:
|
--- Sends an email via mailx command and various options.
--- Note that multiple options are allowed, e.g., more than one CC option
--- for multiple recipient of carbon copies.
---
--- Important note: The implementation of this operation is based on the
--- command "mailx" and must be adapted according to your local environment!
---
--- @param from - the email address of the sender
--- @param subject - the subject of the email
--- @param options - send options, e.g., multiple recipients
--- @param contents - the contents of the email
|