Copyright(c) digitally induced GmbH 2020
Safe HaskellNone

IHP.Mail

Description

 
Synopsis

Documentation

data MailServer Source #

Configuration for a mailer used by IHP

Constructors

SES

Uses AWS SES for sending emails

Sendmail

Uses the local Sendmail binary for sending emails. Avoid this with IHP Cloud

SendGrid

Uses SendGrid for sending emails

Fields

SMTP

Uses a generic SMTP for sending emails

Fields

class BuildMail mail where Source #

Minimal complete definition

subject, to, from, html

Methods

subject :: (?mail :: mail) => Text 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 (get #name user), addressEmail = get #email user }

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
            get #email admin
    }

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>" } ]

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