Copyright | (c) digitally induced GmbH 2020 |
---|---|
Safe Haskell | None |
Synopsis
- data MailServer
- = SES {
- accessKey :: ByteString
- secretKey :: ByteString
- region :: Text
- | Sendmail
- | SendGrid { }
- | SMTP {
- host :: String
- port :: PortNumber
- credentials :: Maybe (String, String)
- encryption :: SMTPEncryption
- = SES {
- class BuildMail mail where
- subject :: Text
- to :: (?context :: context, ConfigProvider context) => mail -> Address
- replyTo :: (?context :: context, ConfigProvider context) => mail -> Maybe Address
- cc :: (?context :: context, ConfigProvider context) => mail -> [Address]
- bcc :: (?context :: context, ConfigProvider context) => mail -> [Address]
- headers :: (?context :: context, ConfigProvider context) => mail -> Headers
- from :: (?mail :: mail, ?context :: context, ConfigProvider context) => Address
- html :: (?context :: context, ConfigProvider context) => mail -> Html
- text :: (?context :: context, ConfigProvider context) => mail -> Text
- attachments :: (?context :: context, ConfigProvider context) => mail -> [MailAttachment]
- data SMTPEncryption
- = Unencrypted
- | TLS
- | STARTTLS
- sendMail :: (BuildMail mail, ?context :: context, ConfigProvider context) => mail -> IO ()
- sendWithMailServer :: MailServer -> Mail -> IO ()
Documentation
data MailServer Source #
SES | Uses AWS SES for sending emails |
| |
Sendmail | Uses the local Sendmail binary for sending emails |
SendGrid | Uses SendGrid for sending emails |
SMTP | Uses a generic SMTP server for sending emails |
|
class BuildMail mail where Source #
You can use ?mail
to make this dynamic based on the given entity
to :: (?context :: context, ConfigProvider context) => mail -> Address Source #
The email receiver
Example:
to ConfirmationMail { .. } = Address { addressName = Just (user.name), addressEmail = user.email }
Example: Send all emails to a fixed email address while in development mode
to CreateAccountMail { .. } = Address { addressName = Just (fullName admin) , addressEmail = if isDevelopment then "staging@example.com" else admin.email }
replyTo :: (?context :: context, ConfigProvider context) => mail -> Maybe Address Source #
Sets an optional reply-to address
cc :: (?context :: context, ConfigProvider context) => mail -> [Address] Source #
Public list of addresses to receive a copy of the mail (CC)
bcc :: (?context :: context, ConfigProvider context) => mail -> [Address] Source #
Hidden list of addresses to receive a copy of the mail (BCC)
headers :: (?context :: context, ConfigProvider context) => mail -> Headers Source #
Custom headers, excluding from
, to
, cc
, bcc
, subject
, and reply-to
Example: Add a custom X-Mailer header
headers CreateAccountMail { .. } = [("X-Mailer", "mail4j 2.17.0")]
from :: (?mail :: mail, ?context :: context, ConfigProvider context) => Address Source #
Your sender address
Example:
from = Address { addressName = "Acme Inc.", addressEmail = "hi@example.com" }
html :: (?context :: context, ConfigProvider context) => mail -> Html Source #
Similiar to a normal html view, HSX can be used here
text :: (?context :: context, ConfigProvider context) => mail -> Text Source #
When no plain text version of the email is specified it falls back to using the html version but striping out all the html tags
attachments :: (?context :: context, ConfigProvider context) => mail -> [MailAttachment] Source #
Optional, mail attachments
Example:
attachments = [ MailAttachment { name = "attached_file.xml", contentType = "application/xml", content = "<xml><hello/></xml>" } ]
data SMTPEncryption Source #
Configuration for a mailer used by IHP
Instances
EnvVarReader SMTPEncryption Source # | Allow reading the env var of an SMTP encryption method. |
Defined in IHP.EnvVar |
sendMail :: (BuildMail mail, ?context :: context, ConfigProvider context) => mail -> IO () Source #
Sends an email
Uses the mail server provided in the controller context, configured in Config/Config.hs
sendWithMailServer :: MailServer -> Mail -> IO () Source #