{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- 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_returnPath,
    sendEmail_configurationSetName,
    sendEmail_sourceArn,
    sendEmail_returnPathArn,
    sendEmail_tags,
    sendEmail_replyToAddresses,
    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.Lens as Lens
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 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,
    -- | The name of the configuration set to use when you send an email using
    -- @SendEmail@.
    SendEmail -> Maybe Text
configurationSetName :: 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,
    -- | 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,
    -- | 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 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 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
(SendEmail -> SendEmail -> Bool)
-> (SendEmail -> SendEmail -> Bool) -> Eq SendEmail
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]
(Int -> ReadS SendEmail)
-> ReadS [SendEmail]
-> ReadPrec SendEmail
-> ReadPrec [SendEmail]
-> Read 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
(Int -> SendEmail -> ShowS)
-> (SendEmail -> String)
-> ([SendEmail] -> ShowS)
-> Show SendEmail
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. SendEmail -> Rep SendEmail x)
-> (forall x. Rep SendEmail x -> SendEmail) -> Generic SendEmail
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:
--
-- '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.
--
-- 'configurationSetName', 'sendEmail_configurationSetName' - The name of the configuration set to use when you send an email using
-- @SendEmail@.
--
-- '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>.
--
-- '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>.
--
-- '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.
--
-- '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.
--
-- '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' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [MessageTag]
-> Maybe [Text]
-> Text
-> Destination
-> Message
-> SendEmail
SendEmail'
    { $sel:returnPath:SendEmail' :: Maybe Text
returnPath = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:configurationSetName:SendEmail' :: Maybe Text
configurationSetName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sourceArn:SendEmail' :: Maybe Text
sourceArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:returnPathArn:SendEmail' :: Maybe Text
returnPathArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:SendEmail' :: Maybe [MessageTag]
tags = Maybe [MessageTag]
forall a. Maybe a
Prelude.Nothing,
      $sel:replyToAddresses:SendEmail' :: Maybe [Text]
replyToAddresses = Maybe [Text]
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 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 :: (Maybe Text -> f (Maybe Text)) -> SendEmail -> f SendEmail
sendEmail_returnPath = (SendEmail -> Maybe Text)
-> (SendEmail -> Maybe Text -> SendEmail)
-> Lens SendEmail SendEmail (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> SendEmail -> f SendEmail
sendEmail_configurationSetName = (SendEmail -> Maybe Text)
-> (SendEmail -> Maybe Text -> SendEmail)
-> Lens SendEmail SendEmail (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> SendEmail -> f SendEmail
sendEmail_sourceArn = (SendEmail -> Maybe Text)
-> (SendEmail -> Maybe Text -> SendEmail)
-> Lens SendEmail SendEmail (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> SendEmail -> f SendEmail
sendEmail_returnPathArn = (SendEmail -> Maybe Text)
-> (SendEmail -> Maybe Text -> SendEmail)
-> Lens SendEmail SendEmail (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe [MessageTag] -> f (Maybe [MessageTag]))
-> SendEmail -> f SendEmail
sendEmail_tags = (SendEmail -> Maybe [MessageTag])
-> (SendEmail -> Maybe [MessageTag] -> SendEmail)
-> Lens
     SendEmail SendEmail (Maybe [MessageTag]) (Maybe [MessageTag])
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) ((Maybe [MessageTag] -> f (Maybe [MessageTag]))
 -> SendEmail -> f SendEmail)
-> ((Maybe [MessageTag] -> f (Maybe [MessageTag]))
    -> Maybe [MessageTag] -> f (Maybe [MessageTag]))
-> (Maybe [MessageTag] -> f (Maybe [MessageTag]))
-> SendEmail
-> f SendEmail
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [MessageTag] [MessageTag] [MessageTag] [MessageTag]
-> Iso
     (Maybe [MessageTag])
     (Maybe [MessageTag])
     (Maybe [MessageTag])
     (Maybe [MessageTag])
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 AnIso [MessageTag] [MessageTag] [MessageTag] [MessageTag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: (Maybe [Text] -> f (Maybe [Text])) -> SendEmail -> f SendEmail
sendEmail_replyToAddresses = (SendEmail -> Maybe [Text])
-> (SendEmail -> Maybe [Text] -> SendEmail)
-> Lens SendEmail SendEmail (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text])) -> SendEmail -> f SendEmail)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> SendEmail
-> f SendEmail
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
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 :: (Text -> f Text) -> SendEmail -> f SendEmail
sendEmail_source = (SendEmail -> Text)
-> (SendEmail -> Text -> SendEmail)
-> Lens SendEmail SendEmail Text Text
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 :: (Destination -> f Destination) -> SendEmail -> f SendEmail
sendEmail_destination = (SendEmail -> Destination)
-> (SendEmail -> Destination -> SendEmail)
-> Lens SendEmail SendEmail Destination 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 :: (Message -> f Message) -> SendEmail -> f SendEmail
sendEmail_message = (SendEmail -> Message)
-> (SendEmail -> Message -> SendEmail)
-> Lens SendEmail SendEmail Message 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 :: SendEmail -> Request SendEmail
request = Service -> SendEmail -> Request SendEmail
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy SendEmail
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SendEmail)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse SendEmail))
-> Logger
-> Service
-> Proxy SendEmail
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SendEmail)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> 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'
            (Int -> Text -> SendEmailResponse)
-> Either String Int -> Either String (Text -> SendEmailResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either String (Text -> SendEmailResponse)
-> Either String Text -> Either String SendEmailResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"MessageId")
      )

instance Prelude.Hashable SendEmail

instance Prelude.NFData SendEmail

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

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

instance Core.ToQuery SendEmail where
  toQuery :: SendEmail -> QueryString
toQuery SendEmail' {Maybe [Text]
Maybe [MessageTag]
Maybe Text
Text
Destination
Message
message :: Message
destination :: Destination
source :: Text
replyToAddresses :: Maybe [Text]
tags :: Maybe [MessageTag]
returnPathArn :: Maybe Text
sourceArn :: Maybe Text
configurationSetName :: Maybe Text
returnPath :: Maybe Text
$sel:message:SendEmail' :: SendEmail -> Message
$sel:destination:SendEmail' :: SendEmail -> Destination
$sel:source:SendEmail' :: SendEmail -> Text
$sel:replyToAddresses:SendEmail' :: SendEmail -> Maybe [Text]
$sel:tags:SendEmail' :: SendEmail -> Maybe [MessageTag]
$sel:returnPathArn:SendEmail' :: SendEmail -> Maybe Text
$sel:sourceArn:SendEmail' :: SendEmail -> Maybe Text
$sel:configurationSetName:SendEmail' :: SendEmail -> Maybe Text
$sel:returnPath:SendEmail' :: SendEmail -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"SendEmail" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-12-01" :: Prelude.ByteString),
        ByteString
"ReturnPath" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
returnPath,
        ByteString
"ConfigurationSetName" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
configurationSetName,
        ByteString
"SourceArn" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
sourceArn,
        ByteString
"ReturnPathArn" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
returnPathArn,
        ByteString
"Tags"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [MessageTag] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([MessageTag] -> QueryString)
-> Maybe [MessageTag] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [MessageTag]
tags),
        ByteString
"ReplyToAddresses"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            ( ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member"
                ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
replyToAddresses
            ),
        ByteString
"Source" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
source,
        ByteString
"Destination" ByteString -> Destination -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Destination
destination,
        ByteString
"Message" ByteString -> Message -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: 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
(SendEmailResponse -> SendEmailResponse -> Bool)
-> (SendEmailResponse -> SendEmailResponse -> Bool)
-> Eq SendEmailResponse
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]
(Int -> ReadS SendEmailResponse)
-> ReadS [SendEmailResponse]
-> ReadPrec SendEmailResponse
-> ReadPrec [SendEmailResponse]
-> Read 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
(Int -> SendEmailResponse -> ShowS)
-> (SendEmailResponse -> String)
-> ([SendEmailResponse] -> ShowS)
-> Show SendEmailResponse
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. SendEmailResponse -> Rep SendEmailResponse x)
-> (forall x. Rep SendEmailResponse x -> SendEmailResponse)
-> Generic SendEmailResponse
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' :: Int -> Text -> SendEmailResponse
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 :: (Int -> f Int) -> SendEmailResponse -> f SendEmailResponse
sendEmailResponse_httpStatus = (SendEmailResponse -> Int)
-> (SendEmailResponse -> Int -> SendEmailResponse)
-> Lens SendEmailResponse SendEmailResponse Int Int
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 :: (Text -> f Text) -> SendEmailResponse -> f SendEmailResponse
sendEmailResponse_messageId = (SendEmailResponse -> Text)
-> (SendEmailResponse -> Text -> SendEmailResponse)
-> Lens SendEmailResponse SendEmailResponse Text Text
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