Search code examples
pythonvonage

Send multiple using Nexmo


How to send multiple numbers using nexmo with python

import nexmo


client = nexmo.Client(key='exxxxx', secret='Qxxxxxx')
client.send_message({
    'from': 'Nexmo',
    'to': '639354758282',
    'text': 'Hello from Nexmo',
})

Solution

  • Does this loop help to send SMS for multiple numbers? Or, you are looking for something else?

    #!/usr/local/bin/python
    
    import nexmo
    
    client = nexmo.Client(key='*******', secret='*********')
    phones = ['Number 1', 'Number 2', 'Number 2']
    
    for phone in phones:
     msg = 'Hello ' + phone + ' from Nexmo'
     response = client.send_message({
        'from': 'Nexmo',
        'to': phone,
        'text': msg,
     })
     print(response)