MailFrom class

Provides an SES domain MAIL FROM resource.

> NOTE: For the MAIL FROM domain to be fully usable, this resource should be paired with the aws.ses.DomainIdentity resource. To validate the MAIL FROM domain, a DNS MX record is required. To pass SPF checks, a DNS TXT record may also be required. See the Amazon SES MAIL FROM documentation for more information.

Example Usage

Domain Identity MAIL FROM

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

// Example SES Domain Identity
const exampleDomainIdentity = new aws.ses.DomainIdentity("example", {domain: "example.com"});
const example = new aws.ses.MailFrom("example", {
    domain: exampleDomainIdentity.domain,
    mailFromDomain: pulumi.interpolate`bounce.${exampleDomainIdentity.domain}`,
});
// Example Route53 MX record
const exampleSesDomainMailFromMx = new aws.route53.Record("example_ses_domain_mail_from_mx", {
    zoneId: exampleAwsRoute53Zone.id,
    name: example.mailFromDomain,
    type: aws.route53.RecordType.MX,
    ttl: 600,
    records: ["10 feedback-smtp.us-east-1.amazonses.com"],
});
// Example Route53 TXT record for SPF
const exampleSesDomainMailFromTxt = new aws.route53.Record("example_ses_domain_mail_from_txt", {
    zoneId: exampleAwsRoute53Zone.id,
    name: example.mailFromDomain,
    type: aws.route53.RecordType.TXT,
    ttl: 600,
    records: ["v=spf1 include:amazonses.com ~all"],
});
import pulumi
import pulumi_aws as aws

# Example SES Domain Identity
example_domain_identity = aws.ses.DomainIdentity("example", domain="example.com")
example = aws.ses.MailFrom("example",
    domain=example_domain_identity.domain,
    mail_from_domain=example_domain_identity.domain.apply(lambda domain: f"bounce.{domain}"))
# Example Route53 MX record
example_ses_domain_mail_from_mx = aws.route53.Record("example_ses_domain_mail_from_mx",
    zone_id=example_aws_route53_zone["id"],
    name=example.mail_from_domain,
    type=aws.route53.RecordType.MX,
    ttl=600,
    records=["10 feedback-smtp.us-east-1.amazonses.com"])
# Example Route53 TXT record for SPF
example_ses_domain_mail_from_txt = aws.route53.Record("example_ses_domain_mail_from_txt",
    zone_id=example_aws_route53_zone["id"],
    name=example.mail_from_domain,
    type=aws.route53.RecordType.TXT,
    ttl=600,
    records=["v=spf1 include:amazonses.com ~all"])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    // Example SES Domain Identity
    var exampleDomainIdentity = new Aws.Ses.DomainIdentity("example", new()
    {
        Domain = "example.com",
    });

    var example = new Aws.Ses.MailFrom("example", new()
    {
        Domain = exampleDomainIdentity.Domain,
        MailFromDomain = exampleDomainIdentity.Domain.Apply(domain => $"bounce.{domain}"),
    });

    // Example Route53 MX record
    var exampleSesDomainMailFromMx = new Aws.Route53.Record("example_ses_domain_mail_from_mx", new()
    {
        ZoneId = exampleAwsRoute53Zone.Id,
        Name = example.MailFromDomain,
        Type = Aws.Route53.RecordType.MX,
        Ttl = 600,
        Records = new[]
        {
            "10 feedback-smtp.us-east-1.amazonses.com",
        },
    });

    // Example Route53 TXT record for SPF
    var exampleSesDomainMailFromTxt = new Aws.Route53.Record("example_ses_domain_mail_from_txt", new()
    {
        ZoneId = exampleAwsRoute53Zone.Id,
        Name = example.MailFromDomain,
        Type = Aws.Route53.RecordType.TXT,
        Ttl = 600,
        Records = new[]
        {
            "v=spf1 include:amazonses.com ~all",
        },
    });

});
package main

import (
	"fmt"

	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/route53"
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/ses"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		// Example SES Domain Identity
		exampleDomainIdentity, err := ses.NewDomainIdentity(ctx, "example", &ses.DomainIdentityArgs{
			Domain: pulumi.String("example.com"),
		})
		if err != nil {
			return err
		}
		example, err := ses.NewMailFrom(ctx, "example", &ses.MailFromArgs{
			Domain: exampleDomainIdentity.Domain,
			MailFromDomain: exampleDomainIdentity.Domain.ApplyT(func(domain string) (string, error) {
				return fmt.Sprintf("bounce.%v", domain), nil
			}).(pulumi.StringOutput),
		})
		if err != nil {
			return err
		}
		// Example Route53 MX record
		_, err = route53.NewRecord(ctx, "example_ses_domain_mail_from_mx", &route53.RecordArgs{
			ZoneId: pulumi.Any(exampleAwsRoute53Zone.Id),
			Name:   example.MailFromDomain,
			Type:   pulumi.String(route53.RecordTypeMX),
			Ttl:    pulumi.Int(600),
			Records: pulumi.StringArray{
				pulumi.String("10 feedback-smtp.us-east-1.amazonses.com"),
			},
		})
		if err != nil {
			return err
		}
		// Example Route53 TXT record for SPF
		_, err = route53.NewRecord(ctx, "example_ses_domain_mail_from_txt", &route53.RecordArgs{
			ZoneId: pulumi.Any(exampleAwsRoute53Zone.Id),
			Name:   example.MailFromDomain,
			Type:   pulumi.String(route53.RecordTypeTXT),
			Ttl:    pulumi.Int(600),
			Records: pulumi.StringArray{
				pulumi.String("v=spf1 include:amazonses.com ~all"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_ses_mailfrom" "example" {
  domain           = aws_ses_domainidentity.example.domain
  mail_from_domain ="bounce.${aws_ses_domainidentity.example.domain}"
}
# Example SES Domain Identity
resource "aws_ses_domainidentity" "example" {
  domain = "example.com"
}
# Example Route53 MX record
resource "aws_route53_record" "example_ses_domain_mail_from_mx" {
  zone_id = exampleAwsRoute53Zone.id
  name    = aws_ses_mailfrom.example.mail_from_domain
  type    = "MX"
  ttl     = "600"
  records = ["10 feedback-smtp.us-east-1.amazonses.com"] # Change to the region in which `aws_ses_domain_identity.example` is created
}
# Example Route53 TXT record for SPF
resource "aws_route53_record" "example_ses_domain_mail_from_txt" {
  zone_id = exampleAwsRoute53Zone.id
  name    = aws_ses_mailfrom.example.mail_from_domain
  type    = "TXT"
  ttl     = "600"
  records = ["v=spf1 include:amazonses.com ~all"]
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ses.DomainIdentity;
import com.pulumi.aws.ses.DomainIdentityArgs;
import com.pulumi.aws.ses.MailFrom;
import com.pulumi.aws.ses.MailFromArgs;
import com.pulumi.aws.route53.Record;
import com.pulumi.aws.route53.RecordArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        // Example SES Domain Identity
        var exampleDomainIdentity = new DomainIdentity("exampleDomainIdentity", DomainIdentityArgs.builder()
            .domain("example.com")
            .build());

        var example = new MailFrom("example", MailFromArgs.builder()
            .domain(exampleDomainIdentity.domain())
            .mailFromDomain(exampleDomainIdentity.domain().applyValue(_domain -> String.format("bounce.%s", _domain)))
            .build());

        // Example Route53 MX record
        var exampleSesDomainMailFromMx = new Record("exampleSesDomainMailFromMx", RecordArgs.builder()
            .zoneId(exampleAwsRoute53Zone.id())
            .name(example.mailFromDomain())
            .type("MX")
            .ttl(600)
            .records("10 feedback-smtp.us-east-1.amazonses.com")
            .build());

        // Example Route53 TXT record for SPF
        var exampleSesDomainMailFromTxt = new Record("exampleSesDomainMailFromTxt", RecordArgs.builder()
            .zoneId(exampleAwsRoute53Zone.id())
            .name(example.mailFromDomain())
            .type("TXT")
            .ttl(600)
            .records("v=spf1 include:amazonses.com ~all")
            .build());

    }
}
resources:
  example:
    type: aws:ses:MailFrom
    properties:
      domain: ${exampleDomainIdentity.domain}
      mailFromDomain: bounce.${exampleDomainIdentity.domain}
  # Example SES Domain Identity
  exampleDomainIdentity:
    type: aws:ses:DomainIdentity
    name: example
    properties:
      domain: example.com
  # Example Route53 MX record
  exampleSesDomainMailFromMx:
    type: aws:route53:Record
    name: example_ses_domain_mail_from_mx
    properties:
      zoneId: ${exampleAwsRoute53Zone.id}
      name: ${example.mailFromDomain}
      type: MX
      ttl: '600'
      records: # Change to the region in which `aws_ses_domain_identity.example` is created
        - 10 feedback-smtp.us-east-1.amazonses.com
  # Example Route53 TXT record for SPF
  exampleSesDomainMailFromTxt:
    type: aws:route53:Record
    name: example_ses_domain_mail_from_txt
    properties:
      zoneId: ${exampleAwsRoute53Zone.id}
      name: ${example.mailFromDomain}
      type: TXT
      ttl: '600'
      records:
        - v=spf1 include:amazonses.com ~all

Email Identity MAIL FROM

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

// Example SES Email Identity
const example = new aws.ses.EmailIdentity("example", {email: "user@example.com"});
const exampleMailFrom = new aws.ses.MailFrom("example", {
    domain: example.email,
    mailFromDomain: "mail.example.com",
});
import pulumi
import pulumi_aws as aws

# Example SES Email Identity
example = aws.ses.EmailIdentity("example", email="user@example.com")
example_mail_from = aws.ses.MailFrom("example",
    domain=example.email,
    mail_from_domain="mail.example.com")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    // Example SES Email Identity
    var example = new Aws.Ses.EmailIdentity("example", new()
    {
        Email = "user@example.com",
    });

    var exampleMailFrom = new Aws.Ses.MailFrom("example", new()
    {
        Domain = example.Email,
        MailFromDomain = "mail.example.com",
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/ses"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		// Example SES Email Identity
		example, err := ses.NewEmailIdentity(ctx, "example", &ses.EmailIdentityArgs{
			Email: pulumi.String("user@example.com"),
		})
		if err != nil {
			return err
		}
		_, err = ses.NewMailFrom(ctx, "example", &ses.MailFromArgs{
			Domain:         example.Email,
			MailFromDomain: pulumi.String("mail.example.com"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

# Example SES Email Identity
resource "aws_ses_emailidentity" "example" {
  email = "user@example.com"
}
resource "aws_ses_mailfrom" "example" {
  domain           = aws_ses_emailidentity.example.email
  mail_from_domain = "mail.example.com"
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ses.EmailIdentity;
import com.pulumi.aws.ses.EmailIdentityArgs;
import com.pulumi.aws.ses.MailFrom;
import com.pulumi.aws.ses.MailFromArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        // Example SES Email Identity
        var example = new EmailIdentity("example", EmailIdentityArgs.builder()
            .email("user@example.com")
            .build());

        var exampleMailFrom = new MailFrom("exampleMailFrom", MailFromArgs.builder()
            .domain(example.email())
            .mailFromDomain("mail.example.com")
            .build());

    }
}
resources:
  # Example SES Email Identity
  example:
    type: aws:ses:EmailIdentity
    properties:
      email: user@example.com
  exampleMailFrom:
    type: aws:ses:MailFrom
    name: example
    properties:
      domain: ${example.email}
      mailFromDomain: mail.example.com

Import

Using pulumi import, import MAIL FROM domain using the domain attribute. For example:

$ pulumi import aws:ses/mailFrom:MailFrom example example.com

Constructors

MailFrom(String name, {MailFromArgs? args, CustomResourceOptions? options})
Creates a new MailFrom. name The Pulumi resource name. args Arguments used to configure this MailFrom. The set of arguments for MailFrom. options Resource options controlling this resource's behavior.
MailFrom.reference(String urn)
Creates a typed reference to an existing MailFrom resource.

Properties

behaviorOnMxFailure ↔ Output<String?>
Action that you want Amazon SES to take if it cannot successfully read the required MX record when you send an email. Defaults to UseDefaultValue. See the SES API documentation for more information.
latefinal
childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
domain ↔ Output<String>
Verified domain name or email identity to generate DKIM tokens for.
latefinal
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
mailFromDomain ↔ Output<String>
Subdomain (of above domain) which is to be used as MAIL FROM address (Required for DMARC validation)
latefinal
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {MailFromState? state, CustomResourceOptions? options}) → MailFrom
Gets an existing MailFrom resource's state with the given name and id.