Enables or disables the custom MAIL FROM domain setup for a verified identity (an email address or a domain).
To send emails using the specified MAIL FROM domain, you must add an MX record to your MAIL FROM domain's DNS settings. To ensure that your emails pass Sender Policy Framework (SPF) checks, you must also add or update an SPF record. For more information, see the Amazon SES Developer Guide.
You can execute this operation no more than once per second.
Parameters:
-
identity
(Identity)
–
-
mail_from_domain
(Optional[MailFromDomainName], default:
None
)
–
The custom MAIL FROM domain for the verified identity to use. The MAIL FROM domain must 1) be a subdomain of the verified identity, 2) not be used in a "From" address if the MAIL FROM domain is the destination of email feedback forwarding (for more information, see the Amazon SES Developer Guide), and 3) not be used to receive emails. A value of null disables the custom MAIL FROM setting for the identity.
-
behavior_on_mx_failure
(Optional[BehaviorOnMXFailure], default:
None
)
–
The action for Amazon SES to take if it cannot successfully read the required MX record when you send an email. If you choose UseDefaultValue, Amazon SES uses amazonses.com (or a subdomain of that) as the MAIL FROM domain. If you choose RejectMessage, Amazon SES returns a MailFromDomainNotVerified error and not send the email.
The action specified in BehaviorOnMXFailure is taken when the custom MAIL FROM domain setup is in the Pending, Failed, and TemporaryFailure states.
Raises:
Examples:
SetIdentityMailFromDomain
The following example configures Amazon SES to use a custom MAIL FROM domain for an identity:
>>> client.set_identity_mail_from_domain(identity='[email protected]', mail_from_domain='bounces.example.com', behavior_on_mx_failure='UseDefaultValue')
Source code in docs_src/capo_ses/_services/ses.py
| def set_identity_mail_from_domain(
self,
identity: "capo_ses.types.identity.Identity",
*,
config_overrides: Optional[SESClientConfig] = None,
mail_from_domain: Optional[
"capo_ses.types.mail_from_domain_name.MailFromDomainName"
] = None,
behavior_on_mx_failure: Optional[
"capo_ses.types.behavior_on_mx_failure.BehaviorOnMXFailure"
] = None,
) -> "capo_ses.types.set_identity_mail_from_domain_response.SetIdentityMailFromDomainResponse":
"""<p>Enables or disables the custom MAIL FROM domain setup for a verified identity (an email address or a domain).</p> <important> <p>To send emails using the specified MAIL FROM domain, you must add an MX record to your MAIL FROM domain's DNS settings. To ensure that your emails pass Sender Policy Framework (SPF) checks, you must also add or update an SPF record. For more information, see the <a href="https://docs.aws.amazon.com/ses/latest/dg/mail-from.html">Amazon SES Developer Guide</a>.</p> </important> <p>You can execute this operation no more than once per second.</p>
Args:
identity: <p>The verified identity.</p>
mail_from_domain: <p>The custom MAIL FROM domain for the verified identity to use. The MAIL FROM domain must 1) be a subdomain of the verified identity, 2) not be used in a "From" address if the MAIL FROM domain is the destination of email feedback forwarding (for more information, see the <a href="https://docs.aws.amazon.com/ses/latest/dg/mail-from.html">Amazon SES Developer Guide</a>), and 3) not be used to receive emails. A value of <code>null</code> disables the custom MAIL FROM setting for the identity.</p>
behavior_on_mx_failure: <p>The action for Amazon SES to take if it cannot successfully read the required MX record when you send an email. If you choose <code>UseDefaultValue</code>, Amazon SES uses amazonses.com (or a subdomain of that) as the MAIL FROM domain. If you choose <code>RejectMessage</code>, Amazon SES returns a <code>MailFromDomainNotVerified</code> error and not send the email.</p> <p>The action specified in <code>BehaviorOnMXFailure</code> is taken when the custom MAIL FROM domain setup is in the <code>Pending</code>, <code>Failed</code>, and <code>TemporaryFailure</code> states.</p>
Raises:
capo_ses.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
SetIdentityMailFromDomain
The following example configures Amazon SES to use a custom MAIL FROM domain for an identity:
>>> client.set_identity_mail_from_domain(identity='[email protected]', mail_from_domain='bounces.example.com', behavior_on_mx_failure='UseDefaultValue')
"""
def _handler(
req: "OperationRequest[capo_ses.types.set_identity_mail_from_domain_request.SetIdentityMailFromDomainRequest]",
) -> OperationResponse[
"capo_ses.types.set_identity_mail_from_domain_response.SetIdentityMailFromDomainResponse"
]:
import capo_ses._operations.simple_email_service.set_identity_mail_from_domain
output, http_response = (
capo_ses._operations.simple_email_service.set_identity_mail_from_domain.set_identity_mail_from_domain(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("SetIdentityMailFromDomain")
)
input_: capo_ses.types.set_identity_mail_from_domain_request.SetIdentityMailFromDomainRequest = {
"identity": identity
}
if mail_from_domain is not None:
input_["mail_from_domain"] = mail_from_domain
if behavior_on_mx_failure is not None:
input_["behavior_on_mx_failure"] = behavior_on_mx_failure
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|