我使用 AWS 发送电子邮件和 SMS 消息。由于 mailer-daemon 返回的电子邮件,我知道失败的电子邮件消息。最近,我停止在我的文本电话上接收 SMS 消息,即使代码运行没有问题并且我获得了 SMS 消息的消息 ID。该代码将 SMS 直接发布到手机,而不是主题。 Python代码是:
import botocore
import boto3
def send_text(message):
boto3.setup_default_session(profile_name='sms')
try:
resource = boto3.resource('sns', region_name="eu-west-1")
response = resource.meta.client.publish(
PhoneNumber=PHONE, Message=message)
message_id = response['MessageId']
print("Published message with text: '%s', id = '%s'." % (message, message_id))
except botocore.exceptions.ClientError:
print("Couldn't publish message.")
raise
并且日志显示:
Published message with text: '..', id = 'f4494169-...'.
我检查了相关区域 (eu-west-1) 的 CloudWatch console,但根本没有看到任何指标,无论是 SES 还是 SNS。 docs 解释了如何监控发布到主题,而不是直接向手机发送消息。
如何调试短信发送并通过短信ID查看发送状态?
答案 0 :(得分:1)
还可以为 SMS 直接发布启用传送状态日志记录。有关如何操作的说明,请参阅 this link。此设置将为从您的帐户在该地区发送的所有 SMS 发出日志,无论它们是通过主题发布还是直接发布。