{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.SES.SendEmail
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Composes an email message and immediately queues it for sending. In
-- order to send email using the @SendEmail@ operation, your message must
-- meet the following requirements:
--
-- -   The message must be sent from a verified email address or domain. If
--     you attempt to send email using a non-verified address or domain,
--     the operation will result in an \"Email address not verified\"
--     error.
--
-- -   If your account is still in the Amazon SES sandbox, you may only
--     send to verified addresses or domains, or to email addresses
--     associated with the Amazon SES Mailbox Simulator. For more
--     information, see
--     <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-addresses-and-domains.html Verifying Email Addresses and Domains>
--     in the /Amazon SES Developer Guide./
--
-- -   The maximum message size is 10 MB.
--
-- -   The message must include at least one recipient email address. The
--     recipient address can be a To: address, a CC: address, or a BCC:
--     address. If a recipient email address is invalid (that is, it is not
--     in the format /UserName\@[SubDomain.]Domain.TopLevelDomain/), the
--     entire message will be rejected, even if the message contains other
--     recipients that are valid.
--
-- -   The message may not include more than 50 recipients, across the To:,
--     CC: and BCC: fields. If you need to send an email message to a
--     larger audience, you can divide your recipient list into groups of
--     50 or fewer, and then call the @SendEmail@ operation several times
--     to send the message to each group.
--
-- For every message that you send, the total number of recipients
-- (including each recipient in the To:, CC: and BCC: fields) is counted
-- against the maximum number of emails you can send in a 24-hour period
-- (your /sending quota/). For more information about sending quotas in
-- Amazon SES, see
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/manage-sending-limits.html Managing Your Amazon SES Sending Limits>
-- in the /Amazon SES Developer Guide./
module Amazonka.SES.SendEmail
  ( -- * Creating a Request
    SendEmail (..),
    newSendEmail,

    -- * Request Lenses
    sendEmail_configurationSetName,
    sendEmail_replyToAddresses,
    sendEmail_returnPath,
    sendEmail_returnPathArn,
    sendEmail_sourceArn,
    sendEmail_tags,
    sendEmail_source,
    sendEmail_destination,
    sendEmail_message,

    -- * Destructuring the Response
    SendEmailResponse (..),
    newSendEmailResponse,

    -- * Response Lenses
    sendEmailResponse_httpStatus,
    sendEmailResponse_messageId,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SES.Types

-- | Represents a request to send a single formatted email using Amazon SES.
-- For more information, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-formatted.html Amazon SES Developer Guide>.
--
-- /See:/ 'newSendEmail' smart constructor.
data SendEmail = SendEmail'
  { -- | The name of the configuration set to use when you send an email using
    -- @SendEmail@.
    SendEmail -> Maybe Text
configurationSetName :: Prelude.Maybe Prelude.Text,
    -- | The reply-to email address(es) for the message. If the recipient replies
    -- to the message, each reply-to address will receive the reply.
    SendEmail -> Maybe [Text]
replyToAddresses :: Prelude.Maybe [Prelude.Text],
    -- | The email address that bounces and complaints will be forwarded to when
    -- feedback forwarding is enabled. If the message cannot be delivered to
    -- the recipient, then an error message will be returned from the
    -- recipient\'s ISP; this message will then be forwarded to the email
    -- address specified by the @ReturnPath@ parameter. The @ReturnPath@
    -- parameter is never overwritten. This email address must be either
    -- individually verified with Amazon SES, or from a domain that has been
    -- verified with Amazon SES.
    SendEmail -> Maybe Text
returnPath :: Prelude.Maybe Prelude.Text,
    -- | This parameter is used only for sending authorization. It is the ARN of
    -- the identity that is associated with the sending authorization policy
    -- that permits you to use the email address specified in the @ReturnPath@
    -- parameter.
    --
    -- For example, if the owner of @example.com@ (which has ARN
    -- @arn:aws:ses:us-east-1:123456789012:identity\/example.com@) attaches a
    -- policy to it that authorizes you to use @feedback\@example.com@, then
    -- you would specify the @ReturnPathArn@ to be
    -- @arn:aws:ses:us-east-1:123456789012:identity\/example.com@, and the
    -- @ReturnPath@ to be @feedback\@example.com@.
    --
    -- For more information about sending authorization, see the
    -- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html Amazon SES Developer Guide>.
    SendEmail -> Maybe Text
returnPathArn :: Prelude.Maybe Prelude.Text,
    -- | This parameter is used only for sending authorization. It is the ARN of
    -- the identity that is associated with the sending authorization policy
    -- that permits you to send for the email address specified in the @Source@
    -- parameter.
    --
    -- For example, if the owner of @example.com@ (which has ARN
    -- @arn:aws:ses:us-east-1:123456789012:identity\/example.com@) attaches a
    -- policy to it that authorizes you to send from @user\@example.com@, then
    -- you would specify the @SourceArn@ to be
    -- @arn:aws:ses:us-east-1:123456789012:identity\/example.com@, and the
    -- @Source@ to be @user\@example.com@.
    --
    -- For more information about sending authorization, see the
    -- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html Amazon SES Developer Guide>.
    SendEmail -> Maybe Text
sourceArn :: Prelude.Maybe Prelude.Text,
    -- | A list of tags, in the form of name\/value pairs, to apply to an email
    -- that you send using @SendEmail@. Tags correspond to characteristics of
    -- the email that you define, so that you can publish email sending events.
    SendEmail -> Maybe [MessageTag]
tags :: Prelude.Maybe [MessageTag],
    -- | The email address that is sending the email. This email address must be
    -- either individually verified with Amazon SES, or from a domain that has
    -- been verified with Amazon SES. For information about verifying
    -- identities, see the
    -- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-addresses-and-domains.html Amazon SES Developer Guide>.
    --
    -- If you are sending on behalf of another user and have been permitted to
    -- do so by a sending authorization policy, then you must also specify the
    -- @SourceArn@ parameter. For more information about sending authorization,
    -- see the
    -- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html Amazon SES Developer Guide>.
    --
    -- Amazon SES does not support the SMTPUTF8 extension, as described in
    -- <https://tools.ietf.org/html/rfc6531 RFC6531>. For this reason, the
    -- /local part/ of a source email address (the part of the email address
    -- that precedes the \@ sign) may only contain
    -- <https://en.wikipedia.org/wiki/Email_address#Local-part 7-bit ASCII characters>.
    -- If the /domain part/ of an address (the part after the \@ sign) contains
    -- non-ASCII characters, they must be encoded using Punycode, as described
    -- in <https://tools.ietf.org/html/rfc3492.html RFC3492>. The sender name
    -- (also known as the /friendly name/) may contain non-ASCII characters.
    -- These characters must be encoded using MIME encoded-word syntax, as
    -- described in <https://tools.ietf.org/html/rfc2047 RFC 2047>. MIME
    -- encoded-word syntax uses the following form:
    -- @=?charset?encoding?encoded-text?=@.
    SendEmail -> Text
source :: Prelude.Text,
    -- | The destination for this email, composed of To:, CC:, and BCC: fields.
    SendEmail -> Destination
destination :: Destination,
    -- | The message to be sent.
    SendEmail -> Message
message :: Message
  }
  deriving (SendEmail -> SendEmail -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendEmail -> SendEmail -> Bool
$c/= :: SendEmail -> SendEmail -> Bool
== :: SendEmail -> SendEmail -> Bool
$c== :: SendEmail -> SendEmail -> Bool
Prelude.Eq, ReadPrec [SendEmail]
ReadPrec SendEmail
Int -> ReadS SendEmail
ReadS [SendEmail]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendEmail]
$creadListPrec :: ReadPrec [SendEmail]
readPrec :: ReadPrec SendEmail
$creadPrec :: ReadPrec SendEmail
readList :: ReadS [SendEmail]
$creadList :: ReadS [SendEmail]
readsPrec :: Int -> ReadS SendEmail
$creadsPrec :: Int -> ReadS SendEmail
Prelude.Read, Int -> SendEmail -> ShowS
[SendEmail] -> ShowS
SendEmail -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendEmail] -> ShowS
$cshowList :: [SendEmail] -> ShowS
show :: SendEmail -> String
$cshow :: SendEmail -> String
showsPrec :: Int -> SendEmail -> ShowS
$cshowsPrec :: Int -> SendEmail -> ShowS
Prelude.Show, forall x. Rep SendEmail x -> SendEmail
forall x. SendEmail -> Rep SendEmail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SendEmail x -> SendEmail
$cfrom :: forall x. SendEmail -> Rep SendEmail x
Prelude.Generic)

-- |
-- Create a value of 'SendEmail' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'configurationSetName', 'sendEmail_configurationSetName' - The name of the configuration set to use when you send an email using
-- @SendEmail@.
--
-- 'replyToAddresses', 'sendEmail_replyToAddresses' - The reply-to email address(es) for the message. If the recipient replies
-- to the message, each reply-to address will receive the reply.
--
-- 'returnPath', 'sendEmail_returnPath' - The email address that bounces and complaints will be forwarded to when
-- feedback forwarding is enabled. If the message cannot be delivered to
-- the recipient, then an error message will be returned from the
-- recipient\'s ISP; this message will then be forwarded to the email
-- address specified by the @ReturnPath@ parameter. The @ReturnPath@
-- parameter is never overwritten. This email address must be either
-- individually verified with Amazon SES, or from a domain that has been
-- verified with Amazon SES.
--
-- 'returnPathArn', 'sendEmail_returnPathArn' - This parameter is used only for sending authorization. It is the ARN of
-- the identity that is associated with the sending authorization policy
-- that permits you to use the email address specified in the @ReturnPath@
-- parameter.
--
-- For example, if the owner of @example.com@ (which has ARN
-- @arn:aws:ses:us-east-1:123456789012:identity\/example.com@) attaches a
-- policy to it that authorizes you to use @feedback\@example.com@, then
-- you would specify the @ReturnPathArn@ to be
-- @arn:aws:ses:us-east-1:123456789012:identity\/example.com@, and the
-- @ReturnPath@ to be @feedback\@example.com@.
--
-- For more information about sending authorization, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html Amazon SES Developer Guide>.
--
-- 'sourceArn', 'sendEmail_sourceArn' - This parameter is used only for sending authorization. It is the ARN of
-- the identity that is associated with the sending authorization policy
-- that permits you to send for the email address specified in the @Source@
-- parameter.
--
-- For example, if the owner of @example.com@ (which has ARN
-- @arn:aws:ses:us-east-1:123456789012:identity\/example.com@) attaches a
-- policy to it that authorizes you to send from @user\@example.com@, then
-- you would specify the @SourceArn@ to be
-- @arn:aws:ses:us-east-1:123456789012:identity\/example.com@, and the
-- @Source@ to be @user\@example.com@.
--
-- For more information about sending authorization, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html Amazon SES Developer Guide>.
--
-- 'tags', 'sendEmail_tags' - A list of tags, in the form of name\/value pairs, to apply to an email
-- that you send using @SendEmail@. Tags correspond to characteristics of
-- the email that you define, so that you can publish email sending events.
--
-- 'source', 'sendEmail_source' - The email address that is sending the email. This email address must be
-- either individually verified with Amazon SES, or from a domain that has
-- been verified with Amazon SES. For information about verifying
-- identities, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-addresses-and-domains.html Amazon SES Developer Guide>.
--
-- If you are sending on behalf of another user and have been permitted to
-- do so by a sending authorization policy, then you must also specify the
-- @SourceArn@ parameter. For more information about sending authorization,
-- see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html Amazon SES Developer Guide>.
--
-- Amazon SES does not support the SMTPUTF8 extension, as described in
-- <https://tools.ietf.org/html/rfc6531 RFC6531>. For this reason, the
-- /local part/ of a source email address (the part of the email address
-- that precedes the \@ sign) may only contain
-- <https://en.wikipedia.org/wiki/Email_address#Local-part 7-bit ASCII characters>.
-- If the /domain part/ of an address (the part after the \@ sign) contains
-- non-ASCII characters, they must be encoded using Punycode, as described
-- in <https://tools.ietf.org/html/rfc3492.html RFC3492>. The sender name
-- (also known as the /friendly name/) may contain non-ASCII characters.
-- These characters must be encoded using MIME encoded-word syntax, as
-- described in <https://tools.ietf.org/html/rfc2047 RFC 2047>. MIME
-- encoded-word syntax uses the following form:
-- @=?charset?encoding?encoded-text?=@.
--
-- 'destination', 'sendEmail_destination' - The destination for this email, composed of To:, CC:, and BCC: fields.
--
-- 'message', 'sendEmail_message' - The message to be sent.
newSendEmail ::
  -- | 'source'
  Prelude.Text ->
  -- | 'destination'
  Destination ->
  -- | 'message'
  Message ->
  SendEmail
newSendEmail :: Text -> Destination -> Message -> SendEmail
newSendEmail Text
pSource_ Destination
pDestination_ Message
pMessage_ =
  SendEmail'
    { $sel:configurationSetName:SendEmail' :: Maybe Text
configurationSetName = forall a. Maybe a
Prelude.Nothing,
      $sel:replyToAddresses:SendEmail' :: Maybe [Text]
replyToAddresses = forall a. Maybe a
Prelude.Nothing,
      $sel:returnPath:SendEmail' :: Maybe Text
returnPath = forall a. Maybe a
Prelude.Nothing,
      $sel:returnPathArn:SendEmail' :: Maybe Text
returnPathArn = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceArn:SendEmail' :: Maybe Text
sourceArn = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:SendEmail' :: Maybe [MessageTag]
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:source:SendEmail' :: Text
source = Text
pSource_,
      $sel:destination:SendEmail' :: Destination
destination = Destination
pDestination_,
      $sel:message:SendEmail' :: Message
message = Message
pMessage_
    }

-- | The name of the configuration set to use when you send an email using
-- @SendEmail@.
sendEmail_configurationSetName :: Lens.Lens' SendEmail (Prelude.Maybe Prelude.Text)
sendEmail_configurationSetName :: Lens' SendEmail (Maybe Text)
sendEmail_configurationSetName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEmail' {Maybe Text
configurationSetName :: Maybe Text
$sel:configurationSetName:SendEmail' :: SendEmail -> Maybe Text
configurationSetName} -> Maybe Text
configurationSetName) (\s :: SendEmail
s@SendEmail' {} Maybe Text
a -> SendEmail
s {$sel:configurationSetName:SendEmail' :: Maybe Text
configurationSetName = Maybe Text
a} :: SendEmail)

-- | The reply-to email address(es) for the message. If the recipient replies
-- to the message, each reply-to address will receive the reply.
sendEmail_replyToAddresses :: Lens.Lens' SendEmail (Prelude.Maybe [Prelude.Text])
sendEmail_replyToAddresses :: Lens' SendEmail (Maybe [Text])
sendEmail_replyToAddresses = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEmail' {Maybe [Text]
replyToAddresses :: Maybe [Text]
$sel:replyToAddresses:SendEmail' :: SendEmail -> Maybe [Text]
replyToAddresses} -> Maybe [Text]
replyToAddresses) (\s :: SendEmail
s@SendEmail' {} Maybe [Text]
a -> SendEmail
s {$sel:replyToAddresses:SendEmail' :: Maybe [Text]
replyToAddresses = Maybe [Text]
a} :: SendEmail) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The email address that bounces and complaints will be forwarded to when
-- feedback forwarding is enabled. If the message cannot be delivered to
-- the recipient, then an error message will be returned from the
-- recipient\'s ISP; this message will then be forwarded to the email
-- address specified by the @ReturnPath@ parameter. The @ReturnPath@
-- parameter is never overwritten. This email address must be either
-- individually verified with Amazon SES, or from a domain that has been
-- verified with Amazon SES.
sendEmail_returnPath :: Lens.Lens' SendEmail (Prelude.Maybe Prelude.Text)
sendEmail_returnPath :: Lens' SendEmail (Maybe Text)
sendEmail_returnPath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEmail' {Maybe Text
returnPath :: Maybe Text
$sel:returnPath:SendEmail' :: SendEmail -> Maybe Text
returnPath} -> Maybe Text
returnPath) (\s :: SendEmail
s@SendEmail' {} Maybe Text
a -> SendEmail
s {$sel:returnPath:SendEmail' :: Maybe Text
returnPath = Maybe Text
a} :: SendEmail)

-- | This parameter is used only for sending authorization. It is the ARN of
-- the identity that is associated with the sending authorization policy
-- that permits you to use the email address specified in the @ReturnPath@
-- parameter.
--
-- For example, if the owner of @example.com@ (which has ARN
-- @arn:aws:ses:us-east-1:123456789012:identity\/example.com@) attaches a
-- policy to it that authorizes you to use @feedback\@example.com@, then
-- you would specify the @ReturnPathArn@ to be
-- @arn:aws:ses:us-east-1:123456789012:identity\/example.com@, and the
-- @ReturnPath@ to be @feedback\@example.com@.
--
-- For more information about sending authorization, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html Amazon SES Developer Guide>.
sendEmail_returnPathArn :: Lens.Lens' SendEmail (Prelude.Maybe Prelude.Text)
sendEmail_returnPathArn :: Lens' SendEmail (Maybe Text)
sendEmail_returnPathArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEmail' {Maybe Text
returnPathArn :: Maybe Text
$sel:returnPathArn:SendEmail' :: SendEmail -> Maybe Text
returnPathArn} -> Maybe Text
returnPathArn) (\s :: SendEmail
s@SendEmail' {} Maybe Text
a -> SendEmail
s {$sel:returnPathArn:SendEmail' :: Maybe Text
returnPathArn = Maybe Text
a} :: SendEmail)

-- | This parameter is used only for sending authorization. It is the ARN of
-- the identity that is associated with the sending authorization policy
-- that permits you to send for the email address specified in the @Source@
-- parameter.
--
-- For example, if the owner of @example.com@ (which has ARN
-- @arn:aws:ses:us-east-1:123456789012:identity\/example.com@) attaches a
-- policy to it that authorizes you to send from @user\@example.com@, then
-- you would specify the @SourceArn@ to be
-- @arn:aws:ses:us-east-1:123456789012:identity\/example.com@, and the
-- @Source@ to be @user\@example.com@.
--
-- For more information about sending authorization, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html Amazon SES Developer Guide>.
sendEmail_sourceArn :: Lens.Lens' SendEmail (Prelude.Maybe Prelude.Text)
sendEmail_sourceArn :: Lens' SendEmail (Maybe Text)
sendEmail_sourceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEmail' {Maybe Text
sourceArn :: Maybe Text
$sel:sourceArn:SendEmail' :: SendEmail -> Maybe Text
sourceArn} -> Maybe Text
sourceArn) (\s :: SendEmail
s@SendEmail' {} Maybe Text
a -> SendEmail
s {$sel:sourceArn:SendEmail' :: Maybe Text
sourceArn = Maybe Text
a} :: SendEmail)

-- | A list of tags, in the form of name\/value pairs, to apply to an email
-- that you send using @SendEmail@. Tags correspond to characteristics of
-- the email that you define, so that you can publish email sending events.
sendEmail_tags :: Lens.Lens' SendEmail (Prelude.Maybe [MessageTag])
sendEmail_tags :: Lens' SendEmail (Maybe [MessageTag])
sendEmail_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEmail' {Maybe [MessageTag]
tags :: Maybe [MessageTag]
$sel:tags:SendEmail' :: SendEmail -> Maybe [MessageTag]
tags} -> Maybe [MessageTag]
tags) (\s :: SendEmail
s@SendEmail' {} Maybe [MessageTag]
a -> SendEmail
s {$sel:tags:SendEmail' :: Maybe [MessageTag]
tags = Maybe [MessageTag]
a} :: SendEmail) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The email address that is sending the email. This email address must be
-- either individually verified with Amazon SES, or from a domain that has
-- been verified with Amazon SES. For information about verifying
-- identities, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-addresses-and-domains.html Amazon SES Developer Guide>.
--
-- If you are sending on behalf of another user and have been permitted to
-- do so by a sending authorization policy, then you must also specify the
-- @SourceArn@ parameter. For more information about sending authorization,
-- see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html Amazon SES Developer Guide>.
--
-- Amazon SES does not support the SMTPUTF8 extension, as described in
-- <https://tools.ietf.org/html/rfc6531 RFC6531>. For this reason, the
-- /local part/ of a source email address (the part of the email address
-- that precedes the \@ sign) may only contain
-- <https://en.wikipedia.org/wiki/Email_address#Local-part 7-bit ASCII characters>.
-- If the /domain part/ of an address (the part after the \@ sign) contains
-- non-ASCII characters, they must be encoded using Punycode, as described
-- in <https://tools.ietf.org/html/rfc3492.html RFC3492>. The sender name
-- (also known as the /friendly name/) may contain non-ASCII characters.
-- These characters must be encoded using MIME encoded-word syntax, as
-- described in <https://tools.ietf.org/html/rfc2047 RFC 2047>. MIME
-- encoded-word syntax uses the following form:
-- @=?charset?encoding?encoded-text?=@.
sendEmail_source :: Lens.Lens' SendEmail Prelude.Text
sendEmail_source :: Lens' SendEmail Text
sendEmail_source = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEmail' {Text
source :: Text
$sel:source:SendEmail' :: SendEmail -> Text
source} -> Text
source) (\s :: SendEmail
s@SendEmail' {} Text
a -> SendEmail
s {$sel:source:SendEmail' :: Text
source = Text
a} :: SendEmail)

-- | The destination for this email, composed of To:, CC:, and BCC: fields.
sendEmail_destination :: Lens.Lens' SendEmail Destination
sendEmail_destination :: Lens' SendEmail Destination
sendEmail_destination = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEmail' {Destination
destination :: Destination
$sel:destination:SendEmail' :: SendEmail -> Destination
destination} -> Destination
destination) (\s :: SendEmail
s@SendEmail' {} Destination
a -> SendEmail
s {$sel:destination:SendEmail' :: Destination
destination = Destination
a} :: SendEmail)

-- | The message to be sent.
sendEmail_message :: Lens.Lens' SendEmail Message
sendEmail_message :: Lens' SendEmail Message
sendEmail_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEmail' {Message
message :: Message
$sel:message:SendEmail' :: SendEmail -> Message
message} -> Message
message) (\s :: SendEmail
s@SendEmail' {} Message
a -> SendEmail
s {$sel:message:SendEmail' :: Message
message = Message
a} :: SendEmail)

instance Core.AWSRequest SendEmail where
  type AWSResponse SendEmail = SendEmailResponse
  request :: (Service -> Service) -> SendEmail -> Request SendEmail
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy SendEmail
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SendEmail)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"SendEmailResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> Text -> SendEmailResponse
SendEmailResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"MessageId")
      )

instance Prelude.Hashable SendEmail where
  hashWithSalt :: Int -> SendEmail -> Int
hashWithSalt Int
_salt SendEmail' {Maybe [Text]
Maybe [MessageTag]
Maybe Text
Text
Destination
Message
message :: Message
destination :: Destination
source :: Text
tags :: Maybe [MessageTag]
sourceArn :: Maybe Text
returnPathArn :: Maybe Text
returnPath :: Maybe Text
replyToAddresses :: Maybe [Text]
configurationSetName :: Maybe Text
$sel:message:SendEmail' :: SendEmail -> Message
$sel:destination:SendEmail' :: SendEmail -> Destination
$sel:source:SendEmail' :: SendEmail -> Text
$sel:tags:SendEmail' :: SendEmail -> Maybe [MessageTag]
$sel:sourceArn:SendEmail' :: SendEmail -> Maybe Text
$sel:returnPathArn:SendEmail' :: SendEmail -> Maybe Text
$sel:returnPath:SendEmail' :: SendEmail -> Maybe Text
$sel:replyToAddresses:SendEmail' :: SendEmail -> Maybe [Text]
$sel:configurationSetName:SendEmail' :: SendEmail -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
configurationSetName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
replyToAddresses
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
returnPath
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
returnPathArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [MessageTag]
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
source
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Destination
destination
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Message
message

instance Prelude.NFData SendEmail where
  rnf :: SendEmail -> ()
rnf SendEmail' {Maybe [Text]
Maybe [MessageTag]
Maybe Text
Text
Destination
Message
message :: Message
destination :: Destination
source :: Text
tags :: Maybe [MessageTag]
sourceArn :: Maybe Text
returnPathArn :: Maybe Text
returnPath :: Maybe Text
replyToAddresses :: Maybe [Text]
configurationSetName :: Maybe Text
$sel:message:SendEmail' :: SendEmail -> Message
$sel:destination:SendEmail' :: SendEmail -> Destination
$sel:source:SendEmail' :: SendEmail -> Text
$sel:tags:SendEmail' :: SendEmail -> Maybe [MessageTag]
$sel:sourceArn:SendEmail' :: SendEmail -> Maybe Text
$sel:returnPathArn:SendEmail' :: SendEmail -> Maybe Text
$sel:returnPath:SendEmail' :: SendEmail -> Maybe Text
$sel:replyToAddresses:SendEmail' :: SendEmail -> Maybe [Text]
$sel:configurationSetName:SendEmail' :: SendEmail -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
configurationSetName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
replyToAddresses
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
returnPath
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
returnPathArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourceArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [MessageTag]
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
source
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Destination
destination
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Message
message

instance Data.ToHeaders SendEmail where
  toHeaders :: SendEmail -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath SendEmail where
  toPath :: SendEmail -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery SendEmail where
  toQuery :: SendEmail -> QueryString
toQuery SendEmail' {Maybe [Text]
Maybe [MessageTag]
Maybe Text
Text
Destination
Message
message :: Message
destination :: Destination
source :: Text
tags :: Maybe [MessageTag]
sourceArn :: Maybe Text
returnPathArn :: Maybe Text
returnPath :: Maybe Text
replyToAddresses :: Maybe [Text]
configurationSetName :: Maybe Text
$sel:message:SendEmail' :: SendEmail -> Message
$sel:destination:SendEmail' :: SendEmail -> Destination
$sel:source:SendEmail' :: SendEmail -> Text
$sel:tags:SendEmail' :: SendEmail -> Maybe [MessageTag]
$sel:sourceArn:SendEmail' :: SendEmail -> Maybe Text
$sel:returnPathArn:SendEmail' :: SendEmail -> Maybe Text
$sel:returnPath:SendEmail' :: SendEmail -> Maybe Text
$sel:replyToAddresses:SendEmail' :: SendEmail -> Maybe [Text]
$sel:configurationSetName:SendEmail' :: SendEmail -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"SendEmail" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-12-01" :: Prelude.ByteString),
        ByteString
"ConfigurationSetName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
configurationSetName,
        ByteString
"ReplyToAddresses"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            ( forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member"
                forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
replyToAddresses
            ),
        ByteString
"ReturnPath" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
returnPath,
        ByteString
"ReturnPathArn" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
returnPathArn,
        ByteString
"SourceArn" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
sourceArn,
        ByteString
"Tags"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            (forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [MessageTag]
tags),
        ByteString
"Source" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
source,
        ByteString
"Destination" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Destination
destination,
        ByteString
"Message" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Message
message
      ]

-- | Represents a unique message ID.
--
-- /See:/ 'newSendEmailResponse' smart constructor.
data SendEmailResponse = SendEmailResponse'
  { -- | The response's http status code.
    SendEmailResponse -> Int
httpStatus :: Prelude.Int,
    -- | The unique message identifier returned from the @SendEmail@ action.
    SendEmailResponse -> Text
messageId :: Prelude.Text
  }
  deriving (SendEmailResponse -> SendEmailResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendEmailResponse -> SendEmailResponse -> Bool
$c/= :: SendEmailResponse -> SendEmailResponse -> Bool
== :: SendEmailResponse -> SendEmailResponse -> Bool
$c== :: SendEmailResponse -> SendEmailResponse -> Bool
Prelude.Eq, ReadPrec [SendEmailResponse]
ReadPrec SendEmailResponse
Int -> ReadS SendEmailResponse
ReadS [SendEmailResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendEmailResponse]
$creadListPrec :: ReadPrec [SendEmailResponse]
readPrec :: ReadPrec SendEmailResponse
$creadPrec :: ReadPrec SendEmailResponse
readList :: ReadS [SendEmailResponse]
$creadList :: ReadS [SendEmailResponse]
readsPrec :: Int -> ReadS SendEmailResponse
$creadsPrec :: Int -> ReadS SendEmailResponse
Prelude.Read, Int -> SendEmailResponse -> ShowS
[SendEmailResponse] -> ShowS
SendEmailResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendEmailResponse] -> ShowS
$cshowList :: [SendEmailResponse] -> ShowS
show :: SendEmailResponse -> String
$cshow :: SendEmailResponse -> String
showsPrec :: Int -> SendEmailResponse -> ShowS
$cshowsPrec :: Int -> SendEmailResponse -> ShowS
Prelude.Show, forall x. Rep SendEmailResponse x -> SendEmailResponse
forall x. SendEmailResponse -> Rep SendEmailResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SendEmailResponse x -> SendEmailResponse
$cfrom :: forall x. SendEmailResponse -> Rep SendEmailResponse x
Prelude.Generic)

-- |
-- Create a value of 'SendEmailResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'httpStatus', 'sendEmailResponse_httpStatus' - The response's http status code.
--
-- 'messageId', 'sendEmailResponse_messageId' - The unique message identifier returned from the @SendEmail@ action.
newSendEmailResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'messageId'
  Prelude.Text ->
  SendEmailResponse
newSendEmailResponse :: Int -> Text -> SendEmailResponse
newSendEmailResponse Int
pHttpStatus_ Text
pMessageId_ =
  SendEmailResponse'
    { $sel:httpStatus:SendEmailResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:messageId:SendEmailResponse' :: Text
messageId = Text
pMessageId_
    }

-- | The response's http status code.
sendEmailResponse_httpStatus :: Lens.Lens' SendEmailResponse Prelude.Int
sendEmailResponse_httpStatus :: Lens' SendEmailResponse Int
sendEmailResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEmailResponse' {Int
httpStatus :: Int
$sel:httpStatus:SendEmailResponse' :: SendEmailResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: SendEmailResponse
s@SendEmailResponse' {} Int
a -> SendEmailResponse
s {$sel:httpStatus:SendEmailResponse' :: Int
httpStatus = Int
a} :: SendEmailResponse)

-- | The unique message identifier returned from the @SendEmail@ action.
sendEmailResponse_messageId :: Lens.Lens' SendEmailResponse Prelude.Text
sendEmailResponse_messageId :: Lens' SendEmailResponse Text
sendEmailResponse_messageId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEmailResponse' {Text
messageId :: Text
$sel:messageId:SendEmailResponse' :: SendEmailResponse -> Text
messageId} -> Text
messageId) (\s :: SendEmailResponse
s@SendEmailResponse' {} Text
a -> SendEmailResponse
s {$sel:messageId:SendEmailResponse' :: Text
messageId = Text
a} :: SendEmailResponse)

instance Prelude.NFData SendEmailResponse where
  rnf :: SendEmailResponse -> ()
rnf SendEmailResponse' {Int
Text
messageId :: Text
httpStatus :: Int
$sel:messageId:SendEmailResponse' :: SendEmailResponse -> Text
$sel:httpStatus:SendEmailResponse' :: SendEmailResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
messageId