Sending an MMS message
You can use the AWS CLI or AWS End User Messaging SMS and voice v2 API to send MMS messages to your customers.
Use the send-media-message AWS CLI command to send an MMS message. For more information on configuring the AWS CLI, see Configure the AWS CLI in the AWS Command Line Interface User Guide.
Important
MMS capabilities are only available in some countries. For more information on supported countries for SMS and MMS, see Supported countries and regions for SMS messaging and Supported countries and regions for MMS messaging.
To check if you origination identity is MMS capable, see Phone number status and capabilities.
Before sending an MMS message you need to upload your media files to an Amazon S3 bucket that is in the same AWS Region as your MMS capable origination identity, see Setting up a bucket in S3 for MMS files.
The identity used to call send-media-message
must have read access to
the Amazon S3 bucket that contains your media files. For more information on setting read
access, see Identity-based policy examples for Amazon S3 in the Amazon S3 User Guide.
To send an MMS message
-
At the command line, enter the following command:
aws pinpoint-sms-voice-v2 --region '
us-east-1
' send-media-message --destination-phone-number+12065550150
--origination-identity+14255550120
--message-body 'text body
' --media-urls 's3://s3-bucket/media_file.jpg
'In the preceding command, make the following changes:
-
Replace
us-east-1
with the AWS Region that your origination identity is stored in. -
Replace
+12065550150
with the destination phone number. -
Replace
+14255550120
with your origination identity. The origination identity must beACTIVE
and able to send the destination phone number. -
Replace
text body
with your text message. -
Replace
s3://s3-bucket/media_file.jpg
with the S3 URI of the media file. Supported media file formats are listed in MMS file types, size and character limits. For more information about creating an S3 bucket and managing objects, see Setting up a bucket in S3 for MMS files or Creating a bucket and Uploading objects in the Amazon S3 User Guide.
-
If AWS End User Messaging SMS accepts the command you will receive the MessageID
. This only means
the command was successfully received and not that the destination device has received the
message yet. For a list of error codes, see SendMediaMessage Errors.
{
"MessageId": "string"
}
Setting up a bucket in S3 for MMS files
Your MMS files must be stored in an Amazon S3 bucket. The Amazon S3 bucket must be in the same AWS account and AWS Region as your MMS capable origination identity. These directions show how to create an Amazon S3 bucket, upload a file, and build the URI to the file. For more information on Amazon S3 commands, see Use high-level (s3) commands with the AWS CLI. For more information on configuring the AWS CLI, see Configure the AWS CLI in the AWS Command Line Interface User Guide.
To create an Amazon S3 bucket use the create-bucket
aws s3api create-bucket --region '
us-east-1
' --bucketBucketName
In the preceding command:
-
Replace
us-east-1
with the AWS Region your MMS capable origination identity is in. Replace
BucketName
with the name of the new bucket.
To copy a file to the Amazon S3 bucket use the cp AWS CLI command. At the command line, enter the following command:
aws s3 cp
SourceFilePathAndName
s3://BucketName
/FileName
In the preceding command:
Replace
SourceFilePathAndName
with the file path and name of the file to copy.Replace
BucketName
with the name of the bucket.Replace
FileName
with the name to use for the file.
The URI to use when sending is:
s3://
BucketName
/FileName