SNS cuts off 2 digits from phone number


I'm trying to send text messages via lambda using boto3 sns client. Some messages to through fine but I can see from sns-console that some destination phone numbers are cut short. For example I'm trying to send message to phonenumber "+358501234567". In sns consoles delivery status logs I see that my "destination phone number" is 3585012345. Why does this happen? These messages fail and logs give me the following error: "Unknown error attempting to reach phone"

import json
import boto3

def lambda_handler(event, context):
    sns = boto3.client('sns')
    msgdata = sns.publish(PhoneNumber = "+358XXXXXXX", Message = "Test", Subject = "Alert")
    # TODO implement
    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!')
已提問 2 年前檢視次數 237 次
1 個回答

Dear AWS-User-60837578,

While we where not directly able to reproduce your issue, here are our best attempt suggestions to help you resolve your issue:

  1. Ensure that the number you are trying to reach is valid: SNS follows the E.164, which is an international standards for phone addressing. Standard subscriber numbers are limited to 12 digits.
  2. Ensure your code allows for the maximum possible range of numbers. The given number in your question is longer than the example listed in the code. If you are using some kind of string replacement, it is possible your characters are being left behind there.

Our guide to pushing to mobile phone numbers is here bellow. This includes code samples that utilize our best practices.

Hopefully this helps you solve the issue. We are always happy to respond if you have further questions!

已回答 2 年前

您尚未登入。 登入 去張貼答案。