Safe Haskell | None |
---|---|
Language | Haskell2010 |
Module that implements the Mail API of SendGrid v3.
https://sendgrid.com/docs/API_Reference/api_v3.html
{-# LANGUAGE OverloadedStrings #-} import Data.List.NonEmpty (fromList) import Network.SendGridV3.Api sendGridApiKey :: ApiKey sendGridApiKey = "SG..." testMail :: Mail () () testMail addr = let from' = "john.doe+from@doe.com" subject' = "Email Subject" content' = fromList [mailContentText "Example Content"] in mail [] from' subject' content' main :: IO () main = do -- Simple Send statusCode <- sendMail sendGridApiKey testMail -- Send with further options statusCode <- sendMail sendGridApiKey (testMail { _mailSendAt = Just 1516468000 }) return ()
- sendGridAPI :: Text
- data ApiKey = ApiKey {}
- data MailAddress = MailAddress {}
- data MailContent = MailContent {}
- mailContentText :: Text -> MailContent
- mailContentHtml :: Text -> MailContent
- data Personalization = Personalization {}
- personalization :: NonEmpty MailAddress -> Personalization
- data Disposition
- = Inline
- | Attachment
- data MailAttachment = MailAttachment {}
- data Asm = Asm {
- _asmGroupId :: Int
- _asmGroupsToDisplay :: Maybe [Int]
- data Bcc = Bcc {}
- data BypassListManagement = BypassListManagement {}
- data Footer = Footer {}
- data SandboxMode = SandboxMode {}
- data SpamCheck = SpamCheck {}
- data ClickTracking = ClickTracking {}
- data OpenTracking = OpenTracking {}
- data SubscriptionTracking = SubscriptionTracking {}
- data Ganalytics = Ganalytics {}
- data TrackingSettings = TrackingSettings {}
- data MailSettings = MailSettings {}
- data Mail a b = Mail {
- _mailPersonalizations :: [Personalization]
- _mailFrom :: MailAddress
- _mailReplyTo :: Maybe MailAddress
- _mailSubject :: Text
- _mailContent :: NonEmpty MailContent
- _mailAttachments :: Maybe [MailAttachment]
- _mailTemplateId :: Maybe Text
- _mailSections :: Maybe a
- _mailHeaders :: Maybe [(Text, Text)]
- _mailCategories :: Maybe [Text]
- _mailCustomArgs :: Maybe b
- _mailSendAt :: Maybe Int
- _mailBatchId :: Maybe Text
- _mailAsm :: Maybe Asm
- _mailIpPoolName :: Maybe Text
- _mailMailSettings :: Maybe MailSettings
- _mailTrackingSettings :: Maybe TrackingSettings
- mail :: (ToJSON a, ToJSON b) => [Personalization] -> MailAddress -> Text -> NonEmpty MailContent -> Mail a b
- sendMail :: (ToJSON a, ToJSON b) => ApiKey -> Mail a b -> IO Int
Documentation
sendGridAPI :: Text Source #
URL to SendGrid Mail API
Bearer Token for the API
data MailAddress Source #
MailAddress | |
|
data MailContent Source #
MailContent | |
|
mailContentText :: Text -> MailContent Source #
M̀ailContent constructor for text/plain
mailContentHtml :: Text -> MailContent Source #
M̀ailContent constructor for text/html
data Personalization Source #
An array of messages and their metadata. Each object within personalizations can be thought of as an envelope - it defines who should receive an individual message and how that message should be handled.
Personalization | |
|
personalization :: NonEmpty MailAddress -> Personalization Source #
Personalization smart constructor only asking for the mandatory fields
data Disposition Source #
The content-disposition of the attachment specifying how you would like the attachment to be displayed.
Inline | Results in the attached file being displayed automatically within the message. |
Attachment | Results in the attached file requiring some action to be taken before it is displayed (e.g. opening or downloading the file). |
data MailAttachment Source #
MailAttachment | |
|
An object allowing you to specify how to handle unsubscribes.
Asm | |
|
This allows you to have a blind carbon copy automatically sent to the specified email address for every email that is sent.
data BypassListManagement Source #
Allows you to bypass all unsubscribe groups and suppressions to ensure that the email is delivered to every single recipient. This should only be used in emergencies when it is absolutely necessary that every recipient receives your email.
BypassListManagement | |
|
The default footer that you would like included on every email.
Footer | |
|
data SandboxMode Source #
This allows you to send a test email to ensure that your request body is valid and formatted correctly.
SandboxMode | |
|
This allows you to test the content of your email for spam.
SpamCheck | |
|
data ClickTracking Source #
Allows you to track whether a recipient clicked a link in your email.
ClickTracking | |
|
data OpenTracking Source #
Allows you to track whether the email was opened or not.
OpenTracking | |
|
data SubscriptionTracking Source #
Allows you to insert a subscription management link.
SubscriptionTracking | |
|
data Ganalytics Source #
Allows you to enable tracking provided by Google Analytics
Ganalytics | |
|
data TrackingSettings Source #
TrackingSettings | |
|
data MailSettings Source #
A collection of different mail settings that you can use to specify how you would like this email to be handled.
MailSettings | |
|
|
mail :: (ToJSON a, ToJSON b) => [Personalization] -> MailAddress -> Text -> NonEmpty MailContent -> Mail a b Source #