hailgun-0.2.1.0: Mailgun REST api interface for Haskell.

Safe HaskellNone

Mail.Hailgun

Description

Hailgun is a Haskell wrapper around the Mailgun api's that use type safety to ensure that you are sending a valid request to the Mailgun API's. Mailgun is a service that lets you send emails. It also contains a number of other email handling API's that will be implimented in the future.

Synopsis

Documentation

sendEmailSource

Arguments

:: HailgunContext

The Mailgun context to operate in.

-> HailgunMessage

The Hailgun message to be sent.

-> IO (Either HailgunErrorResponse HailgunSendResponse)

The result of the sent email. Either a sent email or a successful send.

Send an email using the Mailgun API's. This method is capable of sending a message over the Mailgun service. All it needs is the appropriate context.

hailgunMessageSource

Arguments

:: MessageSubject

The purpose of the email surmised.

-> MessageContent

The full body of the email.

-> UnverifiedEmailAddress

The email account that the recipients should respond to in order to get back to us.

-> MessageRecipients

The people that should recieve this email.

-> Either HailgunErrorMessage HailgunMessage

Either an error while trying to create a valid message or a valid message.

A method to construct a HailgunMessage. You require a subject, content, From address and people to send the email to and it will give you back a valid Hailgun email message. Or it will error out while trying.

data HailgunMessage Source

A Hailgun Email message that may be sent. It contains important information such as the address that the email is from, the addresses that it should be going to, the subject of the message and the content of the message. Any email that you wish to send via this api must be converted into this structure first. To create a message then please use the hailgunMessage interface.

data HailgunContext Source

When comunnicating to the Mailgun service you need to have some common pieces of information to authenticate successfully. This context encapsulates that required information.

Constructors

HailgunContext 

Fields

hailgunDomain :: String

The domain of the mailgun account that you wish to send the emails through.

hailgunApiKey :: String

The API key for the mailgun account so that you can successfully make requests. Please note that it should include the key prefix.

hailgunProxy :: Maybe Proxy
 

type MessageSubjectSource

Arguments

 = String

Represents a message subject.

data MessageContent Source

Any email content that you wish to send should be encoded into these types before it is sent. Currently, according to the API, you should always send a Text Only part in the email and you can optionally add a nicely formatted HTML version of that email to the sent message.

It is best to send multi-part emails using both text and HTML or text only. Sending HTML only email is not well received by ESPs. (Source)

This API mirrors that advice so that you can always get it right.

Constructors

TextOnly

The Text only version of the message content.

Fields

textContent :: ByteString

The text content that you wish to send (please note that many clients will take the HTML version first if it is present but that the text version is a great fallback).

TextAndHTML

A message that contains both a Text version of the email content and a HTML version of the email content.

Fields

textContent :: ByteString

The text content that you wish to send (please note that many clients will take the HTML version first if it is present but that the text version is a great fallback).

htmlContent :: ByteString

The HTML content that you wish to send.

data MessageRecipients Source

A collection of unverified email recipients separated into the To, CC and BCC groupings that email supports.

Constructors

MessageRecipients 

Fields

recipientsTo :: [UnverifiedEmailAddress]

The people to email directly.

recipientsCC :: [UnverifiedEmailAddress]

The people to "Carbon Copy" into the email. Honestly, why is that term not deprecated yet?

recipientsBCC :: [UnverifiedEmailAddress]

The people to "Blind Carbon Copy" into the email. There really needs to be a better name for this too.

emptyMessageRecipients :: MessageRecipientsSource

No recipients for your email. Useful singleton instance to avoid boilerplate in your code. For example:

 toBob = emptyMessageRecipients { recipientsTo = ["bob@bob.test"] }

type UnverifiedEmailAddressSource

Arguments

 = ByteString

Represents an email address that is not yet verified.

data HailgunSendResponse Source

The response to an email being accepted by the Mailgun API.

Constructors

HailgunSendResponse 

Fields

hsrMessage :: String

The freeform message from the mailgun API.

hsrId :: String

The ID of the message that has been accepted by the Mailgun api.

type HailgunErrorMessage = StringSource

A generic error message that is returned by the Hailgun library.

data HailgunErrorResponse Source

An error that comes from Mailgun or the Hailgun API.

Constructors

HailgunErrorResponse 

Fields

herMessage :: String

A generic message describing the error.

data Page Source

Constructors

Page 

Fields

pageStart :: Integer
 
pageLength :: Integer
 

newtype HailgunTime Source

Constructors

HailgunTime UTCTime 

Instances

toProxy :: String -> Int -> ProxySource