1 Answer
- Newest
- Most votes
- Most comments
1
Hello,
I am afraid that AWS SES doesn't natively support sending confidential emails. The confidential mode is a client side feature.
But there are always some options like:
- You can use a secure service like S3 to store your private email content. The service supports bucket policies and encryption.
- Make sure that the link is protected so that only the intended recipient can access it. This may be accomplished either through the authentication process or by encrypting the link itself using information that only the intended recipient will know.
- To replicate the function of confidential email confidentiality, you can configure your link to expire after a specified amount of time.
- If you want to ensure that the link can only be clicked on once, you can configure your system to mark the link as "used" after it has been clicked, preventing it from being used again.
The following is how to use "send_templated_emails" to send such an email with a link:
#To interact with AWS using Python, we have to import boto3, the AWS SDK
#Exceptions that can be thrown when using AWS services include BotoCoreError and ClientError.
import boto3
from botocore.exceptions import BotoCoreError, ClientError
#Send an email using a template
def send_templated_email():
#Here we have to create an SES client that represents the AWS Simple Email Service
#and we can use it to send emails.
ses_client = boto3.client('ses')
try:
#Here we actually send the email, we call the send_templated_email method of our SES client.
#Source is the sender, and destination is the recipient.
#Template is the name of the template you created in AWS SES.
# TemplateData is the data that will replace the placeholders in your template.
response = ses_client.send_templated_email(
Source='sender@email.com',
Destination={
'ToAddresses': ['recipient@email.com']
},
Template='template_Name',
TemplateData='{ "name":"Mattew", "link":"https://domain.com/securelink" }'
)
#This line indicates that the email was successfully sent if we reach it.
#so, we can print the message ID which can be used for tracking.
print("Email sent! Message ID: ", response['MessageId'])
except (BotoCoreError, ClientError) as error:
#These exceptions will be raised if there's an error when trying to send the email
print("Error sending email: ", error)
#Call the function to send the email.
send_templated_email()
answered 10 months ago
Relevant content
- asked 2 years ago
- asked 9 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
Our organization already has the client side configured correctly. I am able to send and mark emails as confidential by using send_raw_email() method. Here is the code snippet that does this.
raw_message = ( "From: From_Email\r\n" "To: To_Email\r\n" "Subject: Your email subject\r\n" "Sensitivity: company-confidential\r\n" "MIME-Version: 1.0\r\n" "Content-Type: multipart/alternative; boundary=boundary\r\n" "\r\n" "--boundary\r\n" "Content-Type: text/plain; charset=UTF-8\r\n" "\r\n" "This is the plain text content of the email.\r\n" "\r\n" "--boundary\r\n" "Content-Type: text/html; charset=UTF-8\r\n" "\r\n" "<html>" "<body>" "<h1>This is the HTML content of the email.</h1>" "</body>" "</html>" "\r\n" "--boundary--" )
The Sensitivity mentioned in the above code snippet helps me to do it. I want to know what parameters to pass for setting the sensitivity while using send_templated_email() method. Thanks.