{-|
Module: IHP.Mail.Types
Description: Types for emails
Copyright: (c) digitally induced GmbH, 2020
-}
module IHP.Mail.Types
( MailServer (..)
, MailAttachment (..)
, SMTPEncryption (..)
)
where

import IHP.Prelude
import Network.Socket (PortNumber)

-- | Configuration for a mailer used by IHP
data SMTPEncryption = Unencrypted | TLS | STARTTLS

data MailServer =
    -- | Uses AWS SES for sending emails
    SES { MailServer -> ByteString
accessKey :: ByteString
        , MailServer -> ByteString
secretKey :: ByteString
        --  | E.g. @"us-east-1"@ or @"eu-west-1"@
        , MailServer -> Text
region :: Text }
    -- | Uses the local Sendmail binary for sending emails. Avoid this with IHP Cloud
    | Sendmail
    -- | Uses SendGrid for sending emails
    | SendGrid { MailServer -> Text
apiKey :: Text
               , MailServer -> Maybe Text
category :: Maybe Text }
    -- | Uses a generic SMTP server for sending emails
    | SMTP { MailServer -> String
host :: String
           , MailServer -> PortNumber
port :: PortNumber
           -- (Username,Password) combination
           , MailServer -> Maybe (String, String)
credentials :: Maybe (String, String)
           , MailServer -> SMTPEncryption
encryption :: SMTPEncryption }

data MailAttachment = MailAttachment
    { MailAttachment -> Text
name :: Text -- ^ File name of an attachment
    , MailAttachment -> LByteString
content :: LByteString
    , MailAttachment -> Text
contentType :: Text
    } deriving (MailAttachment -> MailAttachment -> Bool
(MailAttachment -> MailAttachment -> Bool)
-> (MailAttachment -> MailAttachment -> Bool) -> Eq MailAttachment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MailAttachment -> MailAttachment -> Bool
$c/= :: MailAttachment -> MailAttachment -> Bool
== :: MailAttachment -> MailAttachment -> Bool
$c== :: MailAttachment -> MailAttachment -> Bool
Eq, Int -> MailAttachment -> ShowS
[MailAttachment] -> ShowS
MailAttachment -> String
(Int -> MailAttachment -> ShowS)
-> (MailAttachment -> String)
-> ([MailAttachment] -> ShowS)
-> Show MailAttachment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MailAttachment] -> ShowS
$cshowList :: [MailAttachment] -> ShowS
show :: MailAttachment -> String
$cshow :: MailAttachment -> String
showsPrec :: Int -> MailAttachment -> ShowS
$cshowsPrec :: Int -> MailAttachment -> ShowS
Show)