Yandex Cloud
Search
Contact UsGet started
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • AI Studio
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
Service page
Yandex Cloud Postbox
Documentation
Yandex Cloud Postbox
  • Getting started
    • All guides
    • Creating an address
    • Domain ownership check
    • Setting up a DMARC policy
    • Sending an email
    • Templating an email
    • Creating a configuration
    • Linking a configuration to an address
    • Write logs
  • Access management
  • Pricing policy
  • Audit Trails events
  • Public materials
  • Release notes

In this article:

  • Getting started
  • Send an email
  • AWS CLI
  • SMTP
  • AWS SDK
  1. Step-by-step guides
  2. Sending an email

Sending an email

Written by
Yandex Cloud
Updated at August 4, 2025
  • Getting started
  • Send an email
    • AWS CLI
    • SMTP
    • AWS SDK

In Yandex Cloud Postbox, you can send an email using the AWS CLI, AWS SDK, or from a mail client over SMTP.

Note

To ensure the security of data transfer, Yandex Cloud Postbox supports TLS protocol versions 1.2 and 1.3.

Getting startedGetting started

  1. Create a service account in the folder as the address. If you create the service account and address in different folders, you will get an error when attempting to send an email.
  2. Assign the postbox.sender role to the service account.
  3. Create a key for the service account:
    • To send an email over SMTP with API key authentication, create an API key. When creating an API key, set the scope for yc.postbox.send. Save the secret key you got in a secure location. You will not be able to view the secret key parameters again after you close the window.

    • To send an email using the AWS CLI or via SMTP with password authentication, create a static access key. Save the ID and secret key to a secure location. You will not be able to view the secret key parameters again after you close the window.

    • To send an email over SMTP with IAM token authentication, create an IAM token.

      This authorization method is suitable for sending emails from functions in Cloud Functions and containers in Serverless Containers, as well as for Compute Cloud VMs linked to a service account. Select this method if you do not want to create and store static access keys.

      Warning

      Note that an IAM token is valid for up to 12 hours. If you need to provide authorization data in the mail client configuration file, use authentication by API key or password.

Send an emailSend an email

AWS CLIAWS CLI

  1. Install the AWS CLI.

  2. Set up the AWS CLI:

    1. Launch the interactive profile setup:
      aws configure
      
    2. Specify the previously obtained key ID of the postbox-user service account:
      AWS Access Key ID [****************ver_]: <service_account_key_ID>
      
    3. Specify the previously obtained secret key of the postbox-user service account:
      AWS Secret Access Key [****************w5lb]: <service_account_secret_key>
      
    4. Specify the ru-central1 default region name:
      Default region name [ru-central1]: ru-central1
      
    5. Specify JSON as the default format for output data:
      Default output format [None]: json
      
  3. Prepare two JSON files:

    • destination.json: File with a list of destination addresses:

      {
        "ToAddresses": ["test@example.com"]
      }
      
    • message.json: File with the subject and content of the email:

      {
        "Simple": {
          "Subject": {
            "Data": "Test message",
            "Charset": "UTF-8"
          },
          "Body": {
            "Text": {
              "Data": "Test message. Hello!",
              "Charset": "UTF-8"
            }
          }
        }
      }
      
  4. Send an email using the AWS CLI:

    aws sesv2 send-email \
      --from-email-address mail@example.com \
      --destination file://destination.json \
      --content file://message.json \
      --endpoint-url https://postbox.cloud.yandex.net
    
  5. Check the mailbox specified in destination.json for the email.

SMTPSMTP

You can send emails via SMTP with authentication by:

  • Service account API key.
  • Password generated from the static access key of your service account.
  • IAM token of your service account.
Authentication with an API key
Password authentication
IAM token authentication
  1. In the SMTP server settings of your email client, specify the following parameters:

    Email client supports STARTTLS

    Email client supports SMTPS instead of STARTTLS

    Server name

    postbox.cloud.yandex.net

    Port

    587

    465

    Username

    ID of the created API key

    Password

    Secret part of the created API key

  2. Send an email using your email client and make sure the specified recipients receive it.

  1. Get a password using the previously created static access key of the service account. To do this, run the generate.py script. Use Python 3 or higher.

    python generate.py <service_account_secret_key>
    
    generate.py
    #!/usr/bin/env python3
    
    import hmac
    import hashlib
    import base64
    import argparse
    import sys
    
    # These values are required to calculate the signature. Do not change them.
    DATE = "20230926"
    SERVICE = "postbox"
    MESSAGE = "SendRawEmail"
    REGION = "ru-central1"
    TERMINAL = "aws4_request"
    VERSION = 0x04
    
    
    def sign(key, msg):
        return hmac.new(key, msg.encode("utf-8"), hashlib.sha256).digest()
    
    
    def calculate_key(secret_access_key):
        signature = sign(("AWS4" + secret_access_key).encode("utf-8"), DATE)
        signature = sign(signature, REGION)
        signature = sign(signature, SERVICE)
        signature = sign(signature, TERMINAL)
        signature = sign(signature, MESSAGE)
        signature_and_version = bytes([VERSION]) + signature
        smtp_password = base64.b64encode(signature_and_version)
        return smtp_password.decode("utf-8")
    
    
    def main():
        if sys.version_info[0] < 3:
            raise Exception("Must be using Python 3")
    
        parser = argparse.ArgumentParser(
            description="Convert a Secret Access Key to an SMTP password."
        )
        parser.add_argument("secret", help="The Secret Access Key to convert.")
        args = parser.parse_args()
    
        print(calculate_key(args.secret))
    
    
    if __name__ == "__main__":
        main()
    
  2. In the SMTP server settings of your email client, specify the following parameters:

    Email client supports STARTTLS

    Email client supports SMTPS instead of STARTTLS

    Server name

    postbox.cloud.yandex.net

    Port

    587

    465

    Username

    ID of the previously created static access key

    Password

    Password obtained in the previous step

  3. Send an email using your email client and make sure the specified recipients receive it.

  1. In your SMTP mail client settings, specify the following parameters:

    Email client supports STARTTLS

    Email client supports SMTPS instead of STARTTLS

    Server name

    postbox.cloud.yandex.net

    Port

    587

    465

    Username

    IAM_TOKEN

    Password

    Service account IAM token

  2. Send an email using your email client and make sure the specified recipients receive it.

AWS SDKAWS SDK

You can send an email using the AWS SDK for .NET Core, Go, JavaScript, and Python. For more details, see these tutorials:

  • Sending emails using AWS SDK for .NET Core
  • Sending emails using AWS SDK for Go
  • Sending emails using the AWS SDK for JavaScript
  • Sending emails using the AWS SDK for Python

Was the article helpful?

Previous
Setting up a DMARC policy
Next
Templating an email
© 2025 Direct Cursus Technology L.L.C.