• Talinn, Estonia
  • support@lnsolutions.ee

Select your language

Sending Emails via AWS SES in Linux: A Step-by-Step Guide

Sending Emails via AWS SES in Linux: A Step-by-Step Guide

Read more on Medium

 

Sending emails via Amazon Simple Email Service (SES) in Linux can be efficiently achieved using the AWS Command Line Interface (CLI). This article outlines the process of setting up and using AWS SES to send emails from a Linux environment. We’ll cover configuring AWS CLI, verifying email addresses, and sending emails programmatically through a Python script.

Prerequisites:

  1. An AWS account.
  2. Linux distribution installed with AWS CLI.

1. Installing and Configuring AWS CLI:

First, ensure you have AWS CLI installed on your Linux system. You can install it via the package manager or download it directly from AWS and follow installation instructions. In Ubuntu based distros the package name is awscli for example.

After installation, configure AWS CLI by running:

aws configure

Enter your AWS access key ID, secret access key, default region name (e.g., eu-west-1), and default output format.

2. Verifying Email Addresses:

Before sending emails via AWS SES, you need to verify the email addresses you’ll be sending from. You can do this either through the AWS Management Console or via AWS CLI.

To verify an email address via AWS CLI:

aws ses verify-email-identity --email-address info@example.com

3. Sending Emails:

Once the email addresses are verified, you can send emails programmatically using AWS SES. Below is a Python script example to send an email:

import boto3

# Create an SES client
ses_client = boto3.client('ses', region_name='eu-west-1') # Replace with your AWS region

# Send the email
response = ses_client.send_email(
Source='info@example.com', # Verified sender email address
Destination={'ToAddresses': ['recipient@example.com']}, # Recipient email address
Message={
'Subject': {'Data': 'Test Email'},
'Body': {'Text': {'Data': 'This is a test email sent from Amazon SES.'}}
}
)
print("Email sent. Message ID:", response['MessageId'])

Ensure you replace 'info@example.com' with your verified sender email address and 'recipient@example.com' with the recipient's email address.

4. Troubleshooting:

  • If you encounter errors during email sending, ensure your AWS IAM user has the necessary permissions to send emails via SES.
  • Check AWS SES sending limits and ensure you’re within them.
  • Verify AWS CLI configurations and ensure they are correct.

Conclusion:

With AWS SES and AWS CLI, sending emails from a Linux environment becomes straightforward and efficient. By following the steps outlined in this guide, you can quickly set up and start sending emails via AWS SES, enabling reliable email delivery for your applications and services.

 

Read more on Medium

recent posts
  • Talinn, Estonia
  • support@lnsolutions.ee
About
We support your software projects and solutions. We specialize in Java Backend, Web development, BPM Workflow design and Bitcoin payment solutions.
Subscribe