Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 229149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:44:30+00:00 2026-05-11T19:44:30+00:00

I’m looking for good performance when sending a lot of e-mails. I have heard

  • 0

I’m looking for good performance when sending a lot of e-mails.

I have heard that the right way to do it is to open a connection send ~20 e-mails and close the connection. And do that over and over again.
Is this correct?

And how does SmtpClient work, does it open a connection for it’s own lifetime? (not IDisposable, so doesn’t look like that)
Or does it open a connection for each e-mail being sent?
Or does it have a connection open all the time?
Or does it have some magic that opens and closes connections when it’s appropriate?

I would like to know so I know how I should initiate the SmtpClient. As a singleton or only for a chunk of messages…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:44:30+00:00Added an answer on May 11, 2026 at 7:44 pm

    It only sends a single MailMessage from a connection. In fact, it doesn’t even properly close the connection. It sends the mail, but then it doesn’t tell the mail server it wants to quit. So, it just leaves it hanging open, until the underlying pooled stream decides to close the socket.

    Here is the internal code from Reflector:

    ...
            this.GetConnection();
            fileMailWriter = this.transport.SendMail((message.Sender != null) ? message.Sender : message.From, recipients, message.BuildDeliveryStatusNotificationString(), out exception);
            }
            catch (Exception exception2)
            {
                if (Logging.On)
                {
                    Logging.Exception(Logging.Web, this, "Send", exception2);
                }
                if ((exception2 is SmtpFailedRecipientException) && !((SmtpFailedRecipientException) exception2).fatal)
                {
                    throw;
                }
                this.Abort();
                if (this.timedOut)
                {
                    throw new SmtpException(SR.GetString("net_timeout"));
                }
                if (((exception2 is SecurityException) || (exception2 is AuthenticationException)) || (exception2 is SmtpException))
                {
                    throw;
                }
                throw new SmtpException(SR.GetString("SmtpSendMailFailure"), exception2);
            }
    

    btw, here is more info about the SmtpClient not issuing the QUIT command.
    https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=146711&wa=wsignin1.0

    Edit: View the dead link above on web.archive.org

    The work-around is to set SmtpClient.ServicePoint.MaxTimeout to 1. This will close the socket faster, however, this doesn’t actually issue the QUIT command.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.