-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Simple library for Google Mail (GMail).
--
-- Easy-to-use library to interact with the Google Mail API.
--
-- Currently only supporting sending mails.
@package gmail-simple
@version 0.1.0.4
-- | Interactions with GMail made simple.
--
--
Sending mails
--
-- For now, only mail sending is implemented. Here's an example:
--
-- First we read the Google key file.
--
--
-- do gkey <- readKeyFile "google-key.json"
--
--
-- Then we start a session. We provide the mail address of the user that
-- will send the mail.
--
--
-- session <- newSession gkey "sender@example.com"
--
--
-- Here's the mail description.
--
--
-- let mail :: Mail Text
-- mail = Mail
-- { mail_sender = "Me"
-- , mail_recipient = "recipient@example.com"
-- , mail_subject = "Example mail"
-- , mail_body = "This is an example mail."
-- }
--
--
-- Finally, we simply send the mail.
--
--
-- sendMail session mail
--
--
-- That's it.
--
-- Importing this library
--
-- I would recommend importing this module qualified. For example:
--
--
-- import qualified Network.GMail.Simple as GMail
--
module Network.GMail.Simple
-- | Google API Key from a service account. You can create one inside your
-- project in Google Cloud. Once you have it, you can download it
-- to a file and read it using readKeyFile.
data Key
Key :: PrivateKey -> Text -> MailAddress -> Key
[private_key] :: Key -> PrivateKey
[private_key_id] :: Key -> Text
[client_email] :: Key -> MailAddress
-- | Read the key file provided by Google Cloud. It throws a
-- FailedToParseKey exception when the file fails to parse.
--
-- If you don't want to read it from a local file, you can use the
-- FromJSON instance of Key to read it. The function
-- readKeyFile is just a wrapper around that.
readKeyFile :: FilePath -> IO Key
-- | A session that can be used to send mails.
--
--
-- - It may be reused.
-- - Multiple threads can use it simultaneously.
--
data Session
-- | Create a new session for the given sender.
newSession :: Key -> MailAddress -> IO Session
-- | A mail address as text.
newtype MailAddress
MailAddress :: Text -> MailAddress
-- | Mail datatype.
data Mail a
Mail :: Text -> MailAddress -> Text -> a -> Mail a
-- | Sender's alias.
[mail_sender] :: Mail a -> Text
-- | The recipient of this mail.
[mail_recipient] :: Mail a -> MailAddress
-- | The subject of this mail.
[mail_subject] :: Mail a -> Text
-- | Polymorphic mail body.
[mail_body] :: Mail a -> a
-- | Send mail using a session. It might throw a FailedToSend
-- exception.
--
-- In order for this to work, the user must have permissions for the
-- https://www.googleapis.com/auth/gmail.send scope.
sendMail :: ToMailBody a => Session -> Mail a -> IO ()
-- | Class of types that can be used as mail body.
class ToMailBody a
-- | Textual representation of the mail body.
toMailBody :: ToMailBody a => a -> Text
-- | Value for the Content-Type header.
mailContentType :: ToMailBody a => proxy a -> MediaType
-- | Exceptions thrown by functions in this library.
data GMailException
-- | A mail failed to be sent. The JSON value contains the error message as
-- sent by Google.
FailedToSend :: Value -> GMailException
-- | A key file failed to parse. The string contains the parsing error.
FailedToParseKey :: String -> GMailException
instance GHC.Show.Show Network.GMail.Simple.GMailException
instance Network.GMail.Simple.ToMailBody Data.Text.Internal.Text
instance Network.GMail.Simple.ToMailBody Text.Blaze.Html.Html
instance GHC.Exception.Type.Exception Network.GMail.Simple.GMailException
instance Data.Aeson.Types.FromJSON.FromJSON Network.GMail.Simple.OAuth
instance Data.Aeson.Types.FromJSON.FromJSON Network.GMail.Simple.Key
instance GHC.Base.Functor Network.GMail.Simple.Mail
instance Data.String.IsString Network.GMail.Simple.MailAddress