Safe Haskell | None |
---|
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.
- sendEmail :: HailgunContext -> HailgunMessage -> IO (Either HailgunErrorResponse HailgunSendResponse)
- hailgunMessage :: MessageSubject -> MessageContent -> UnverifiedEmailAddress -> MessageRecipients -> Either HailgunErrorMessage HailgunMessage
- data HailgunMessage
- data HailgunContext = HailgunContext {}
- type MessageSubject = String
- data MessageContent
- = TextOnly { }
- | TextAndHTML { }
- data MessageRecipients = MessageRecipients {}
- emptyMessageRecipients :: MessageRecipients
- type UnverifiedEmailAddress = ByteString
- data HailgunSendResponse = HailgunSendResponse {
- hsrMessage :: String
- hsrId :: String
- type HailgunErrorMessage = String
- data HailgunErrorResponse = HailgunErrorResponse {
- herMessage :: String
Documentation
:: 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.
:: 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.
HailgunContext | |
|
type MessageSubjectSource
= 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.
TextOnly | The Text only version of the message content. |
| |
TextAndHTML | A message that contains both a Text version of the email content and a HTML version of the email content. |
|
data MessageRecipients Source
A collection of unverified email recipients separated into the To, CC and BCC groupings that email supports.
MessageRecipients | |
|
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
= ByteString | Represents an email address that is not yet verified. |
data HailgunSendResponse Source
The response to an email being accepted by the Mailgun API.
HailgunSendResponse | |
|
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.
HailgunErrorResponse | |
|