How much email can I send?

Discussion in 'Email' started by ChrisW, Feb 16, 2017.

  1. I'm currently (successfully) sending email from my ASP code, using the SmtpClient API.

    I have a new requirement: I must send 'notification' emails to a group of multiple users. The group of users are employees of a single customer, the users are configured as users of the web site, and this will be 'transactional' email (i.e. not spam).

    # What's the maximum number/rate?

    Is there a limit to how many users I can send to? For example, does DiscountASP impose a limit like "no more than 40 recipients at a time"? What rate-limiting have you implemented?

    # What's the best mechanism/implementation?

    Does it make a difference, whether I send 100 messages each with one recipient in the MailMessage.To property, or whether I send one message with 100 recipients in the MailMessage.CC or MailMessage.Bcc properties?

    Should I expect that sending (bulk sending) might take a long time, or might fail temporarily in a recoverable way, for example should I use Window Workflow Foundation (or similar) to invoke SmtpClient.Send (instead of sending from the context of an ASP web transaction response)? If SmtpClient.Send fails should I retry, and after how long?
     
  2. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    Yes. No more than 40 recipients per single email, no more than 1,000 per hour, and no more than 5,000 per 24 hour period.

    Yes. No more than 40 recipients per single email.

    If you space it out to send one message per minute, you'll be fine.
     
    ChrisW and mjp like this.
  3. I assume that's 1000 recipients per hour: will it be necessary to batch those into groups of 40 recipients per email (i.e. 25 emails total), or is it alright to send 1000 separate emails?

    When you wrote "space it out to send one message per minute", I guess you were talking about waiting before a retry-after-failure: may I try to send 1000 emails without rate-limiting, i.e. do the next SmtpClient.Send immediately after the previous SmtpClient.Send completes successfully?
     
  4. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    Sorry, it should be 1,000 emails per hour and each could have 40 recipients. So, 40,000 recipients.

    1 minute was just a suggestion. And no, don't send one immediately after another. Space it out like 10 seconds in between each message, otherwise, you'll be blocked.
     
  5. So if it's possible to send to multiple recipients in each email (e.g. if they don't mind seeing each other's email addresses), would that be more reliable (because that means sending fewer emails in total, and therefore less load on your system)? Or is it less reliable, because some kind of failure associated with one recipient might fail the whole email?

    And am I right in thinking that if SmtpClient.Send is successful, that only means that it has been accepted by your/our mail server, and that there's no guarantee it can or will be delivered to the recipient, and that there's no way for me to discover (using any API or UI) whether any given email was eventually delivered successfully or failed to be delivered?

    "like 10 seconds in between each message" implies a maximum 360 messages per hour, so I guess that "10 seconds" is a ballpark figure, a rough approximation. I would guess or hope also that you wouldn't mind a couple or handful of emails being accidentally sent close together, rather than it's a sustained sequence of many emails which you would especially want to rate-limit.

    "I'll be blocked". Well I was right to ask you then, before I try it; especially before I try it with a real customer/users.

    I'm sorry to ask probing questions about your security, but would this is permanent or a temporary block? What does the block look like at my end: assuming it is SmtpClient.Send throwing a SmtpException, what SmtpStatusCode in the SmtpException is associated with this kind of block? I want to know so that I can write code which either recovers programmatically/automatically, or (if it's a permanent block) which notifies me to intervene with you.

    I understand I'll probably need a different (offsite) email service provider sooner or later, I'm hoping to delay that day and wondering how to use your service reliably and within your rate limits.
     
  6. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    Less reliable because if the email fails to be sent, then 40 recipients would not receive it.

    Correct, but you can tell if it fails because a bounce back message will be sent to the account used to send the email.

    Yes. It was just an approximation. My answer wasn't meant to be taken literally, but to give you an idea of what might be an issue. You'll get a warning communication from us if you exceed any of our limits.

    Temporary block. You'll get a 421 error (I think) -> SMTP can't send.

    Try SendGrid. You can send up to 12,000 per month for free before moving to a paid subscription.
     
    mjp likes this.
  7. I've done some testing -- trying to send 150 messages a time (sending to an @mailinator.com address).

    What I found is that if the delay between messages is 1.25 seconds or more, then 150 messages will send without error (and because of my inter-message delay, it takes 3 minutes to send them).

    If I set the delay between messages to 0.5 seconds, then the first 100 messages are sent but the subsequent messages are blocked.

    The symptoms of a block, as I see it at my end, are a System.Net.Mail.SmtpException (thrown from await smtpClient.SendMailAsync) whose StatusCode value is 0 and whose Message value is "Syntax error, command unrecognized. The server response was:".

    This might be the same kind of error/exception that developers see if their credentials are wrong.

    Anyway if this block is imposed/triggered, then it lasts for 30 minutes: and if I retry sending the offending email once per minute, then it's sent 30 minutes later .
     
  8. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    That sounds about right. There is block imposed for 30 minutes to prevent our servers from being used to spam people.
     

Share This Page