Why sending a mail using Azure email communication service is too slow?

Efraín Ayala Herrera 30 Reputation points
2024-01-29T19:35:35.83+00:00

Hi. We have an azure app that sends email through email communication service. We have noticed that this process is to slow, it takes between 5 an 10 seconds to send a very short confirmation email. The number of sent mails is also small (20 emails per day). We have seen in another post that is possible to use a parameter called WailUntil.Started in order to not wait for all sending process but we dont know how to use this parameter in python. (our app is python) This is the way we send the message right now. poller = client.begin_send(message) result = poller.result() any advice? regards

Azure Communication Services
Azure Communication Services
An Azure communication platform for deploying applications across devices and platforms.
1,233 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Saravanan Ganesan 1,830 Reputation points MVP
    2024-01-29T20:05:31.8833333+00:00

    Hi Efrain ,

    To improve email sending speed using Azure Communication Services in Python, consider using the wait_until_started parameter. Here's an example:

    from azure.communication.sms import SmsClient
    
    # Initialize your SmsClient
    client = SmsClient.from_connection_string("your_connection_string")
    
    # Create the message and send it, using wait_until_started
    poller = client.begin_send(
        from_phone_number="sender_phone_number",
        to_phone_numbers=["recipient_phone_number"],
        message="Your message content",
        wait_until_started=True
    )
    
    # Get the result without waiting for completion
    result = poller.result()
    
    
    
    
    
    
    
    

    Setting wait_until_started to True allows your code to continue execution without waiting for the entire sending process, potentially reducing latency. Regards, Saravanan Ganesan.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.