Solved

SMTP slower for bulk mailing. How to use Exchange server instead using ASP ?

Posted on 2001-08-11
9
335 Views
Last Modified: 2008-02-01
I have an application which is written in ASP which runs on IIS 4 using CDONTS and SMTP server. The problem with this is it is taking a long time to send mails if I want to send the mail to a larger group of recipients. It potentially freezes my server for long time. Looks like the implementation of SMTP is such a way that it will take the message and try to send to each recipient seperately. I heard that Exchange server is the best option in such situation. I have an exchange server running on the same network. Can I use that for sending mails with out using SMTP. Is it just a configuration change or do I need to recode the page to use exchange server. Any one has this kind of experience ? Your help will be highly appreciated
0
Comment
Question by:rsaji
9 Comments
 
LVL 18

Expert Comment

by:mgfranz
Comment Utility
SMTP is the protocol most email servers use to process email, X400, POP3 are others.  Exchange and CDO use SMTP to process email messages.

If you are having problems processing emails, it might just be a problme with the script.

Post your code, but this is what I use to send bulk email.  The address's are stored in a .txt file with other info, I strip out the junk to get just the address then just run a loop on the resulting "match".  To process and send about 500 emails takes only about 5 seconds with CDONTS on my 2000 laptop;

<%
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile("c:\inetpub\wwwroot\xyz.txt",1, true)
     strPhrase = ts.ReadAll
   
Dim objRegEx, Match, Matches, StrReturnStr
Set objRegEx = New RegExp
objRegEx.Global = True
objRegEx.IgnoreCase = True
objRegEx.Pattern = "~[^/]*"
Set Matches = objRegEx.Execute(strPhrase)

For Each Match in Matches

     theStr = Match.value
     theStr = Replace(theStr, "~", "")
          strTo = theStr&"@pe.net"
          strSubject = "Updates"
          strBody = "This message is being sent as a courtesy to all subscribers.  "
     strBody = strBody & vbCrLf  
     strBody = strBody & "I may not be getting to every subscriber, if you know someone who is on the xyz.Net system, please inform them of this issue."

Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
objCDOMail.From = "Mark G. Franz <mgfranz@pe.net>"
     objCDOMail.To = strTo
     objCDOMail.Subject = strSubject
     objCDOMail.Body = strBody
objCDOMail.Send
Set objCDOMail = Nothing
' Now write out who received the message.
Response.Write "Message sent to " & strTo & "!<br>"

   Next
%>
0
 
LVL 1

Author Comment

by:rsaji
Comment Utility
mgfranz,
I am using the same code to send tha mail. But the difference is I will be sending the mail to 8000 recipients, all in different mail servers(ie x@hotmail.com, y@yahoo.com, z@usa.net etc). In your case you are sending the mail to the a set of recipients in the same server, that is why it may be faster. In this case case we are using the SMTP server. The alternative I am looking for is the Exchange server one with out using the SMTP server. The protocol internally used by Exchange server may be SMTP.
0
 
LVL 18

Expert Comment

by:mgfranz
Comment Utility
It's irrelevant that the recipients are on the same domain, remember, once the message has been processed and sent out on the internet cloud, SMTP and CDO don't care where it goes.  Once the message is processed, my script sends the next one.

I think you may have something else going on... Post your code.
0
 
LVL 1

Author Comment

by:rsaji
Comment Utility
mgfranz,
Here is my code. I am using html format for the mail body

          RecepList = ""
          SQL = "select emailaddress from users"
          set objRs = Server.CreateObject("ADODB.Recordset")
          objRs.CursorType = 3
          objRs.Open SQL, objConn, , , 1
          if objRs.eof = false then
               objRs.MoveFirst
               while objRs.EOF = false
                    if instr(1, objRs.Fields(0).Value, "@") > 0 then
                         if RecepList = "" then
                              RecepList = RecepList & objRs.Fields(0).Value
                         else
                              RecepList = RecepList & ";" & objRs.Fields(0).Value
                         end if
                    end if
                    objRs.MoveNext
               wend
               objRs.Close
               set objRs = nothing
          end if

          strBody = "<!DOCTYPE HTML PUBLIC""-//IETF//DTD HTML//EN"">"
          strBody = strBody & "<html>"
          strBody = strBody & "<head>"
          strBody = strBody & "<title>" & Request.Form("txtSubject").item & "</title>"
          strBody = strBody & "</head>"
          strBody = strBody & "<body bgcolor=""FFFFFF"">"
          if Request.Form("txtFontSize").Item  = "" then
               strBody = strBody & "<p><font size =""2"" face=" & Request.Form("cboFontType").Item & ">"
          else
               strBody = strBody & "<p><font size =" & Request.Form("txtFontSize").Item & " face=" & Request.Form("cboFontType").Item & ">"
          end if
          strBody = strBody & Replace(Request.Form("txtText").Item, chr(10), "<BR>")
          if Request.Form("txtLink").Item <> "" then
               strBody = strBody & "<BR><BR>" & "For more information click on the following link"  
               strBody = strBody & "<BR>" &  "<a href=" & Request.Form("txtLink").Item & ">" & Request.Form("txtLink").Item & "</a>"
          end if
          strBody = strBody & "<BR><BR><BR><I>Disclaimer:<BR><BR>"
          strBody = strBody & Request.Form("txtDisclaimer").Item
          strBody = strBody & "<BR><HR>" & Request.Form("txtCopyright").Item  & "</I>"
          strBody = strBody & "</body>"
          strBody = strBody & "</html>"
          Set objMail = Server.CreateObject("CDONTS.NewMail")
          objMail.To = "User"
          objMail.Bcc = RecepList                                   'set 'To' address
          if Request.Form("txtReturn").Item <> "" then
               objMail.From = Request.Form("txtReturn").Item                    'set 'From' address
               objMail.Value("Reply-To") = Request.Form("txtReturn").Item 'set'Reply to' address
          else
               objMail.From = "Unknown"
               objMail.Value("Reply-To") = "Unknown"
          end if
          objMail.Subject = Request.Form("txtSubject").item     'set the subject line
          objMail.BodyFormat=0 'for html data
          objMail.MailFormat=0    
          objMail.Body = strBody                                        
          objMail.Send                                                            'and send the message
          Set objMail = Nothing                                                  'then destroy the component
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 18

Accepted Solution

by:
mgfranz earned 100 total points
Comment Utility
Oh I see... you are creating a single message with BCC: as the recipient list.  It has been my experience that this is going to be much slower than sending messages on a loop, let's think about this for a second.  In BCC: mail, I need to first create a list of names, then send a message to each recipient at a single time.  If I loop through the names, and send a message to each recipient, I don't create an array list, and I don't send a bulk email, but individual messages.

Trust me, it is faster to send 1 messages to 1 recipient 1000 times than to send 1 message to 1000 recipients 1 times.  The message has to go through the entire list of names and send the message over and over again, with a simple loop, the message gets sent once, then again...  follow?
0
 
LVL 33

Expert Comment

by:hongjun
Comment Utility
Check out your this opened question. Try to do something to it.
http://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=11980878

hongjun
0
 
LVL 2

Expert Comment

by:MCM
Comment Utility
Under properties for SMTP server is IIS console, go to delivery/advanced/smart host. I've never done it, but I beleive ou can specify the address of your exchange server as the smart host. SMTP virutal server will then send the exchange server all of your messages, and let exchange server sort out the delivery. I don't know how SMTP & Exchange shake hands, perhaps someone else will be able to fill in the authentication details. But i think this is the general procedure.

The name JMail gets bandied about a lot as an alternative to CDONTS, but I know nothing about whether you can instruct it to hand off responsibility for message delivery to Exchange. But again, some else may be able to supply some more information.
0
 
LVL 7

Expert Comment

by:John844
Comment Utility
part of your bottle neck might be 8000 string concatanations.  str = str & "something else"

when you are working with string concatanation, the larger the string gets, the slower it gets.  You might try commenting out the portion that sends the email to verify where your bottleneck is.

You might also try sending the email message out for every 50 entries. (if bottleneck is in string concatanation)
0
 
LVL 18

Expert Comment

by:mgfranz
Comment Utility
JMail uses either a local or remote SMTP server, so it really isn't a solution...
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now