Solved

CDO Message + trap invalid mail addresses

Posted on 2004-08-23
13
465 Views
Last Modified: 2008-01-09
Hi.

I use CDO to send activation codes to new members of my password protected site. Now, sometimes people get funny and submit addresses that don't exist, meaning I get a "Mail not delivered" mail back. Sometimes I need to remind people that haven't activated their accounts that they should do so, meaning I've written a script that takes stuff out of the database and mails a reminder to the members who haven't activated their account. But if someone has entered a faulty mail address, the script of course stops givng me an error and stops the execution.

I somehow need to trap this event and just skip that particular mail and jump to the next.

How is this done?
0
Comment
Question by:bobamatics
  • 8
  • 5
13 Comments
 
LVL 31

Expert Comment

by:alorentz
ID: 11876221
Send email through regex first:

Function RegExpTest(sEmail)
  RegExpTest = false
  Dim regEx, retVal
  Set regEx = New RegExp

  ' Create regular expression:
  regEx.Pattern ="^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$"

  ' Set pattern:
  regEx.IgnoreCase = true

  ' Set case sensitivity.
  retVal = regEx.Test(sEmail)

  ' Execute the search test.
  If not retVal Then
    exit function
  End If

  RegExpTest = true
End Function

If it returns tru then it is good, and you should send.  This check email address format, not whether the address exists.  No easy to check if exists.
0
 

Author Comment

by:bobamatics
ID: 11876253
I already have a function to check if the address is in a valid format, what I need is being able to trap when the script halts due to the error given by the mail server.

The error is 8004020f and means "The transport failed to connect to the server." which in this case means it couldn't be sent because the mail address doesn't even exists.
0
 
LVL 31

Expert Comment

by:alorentz
ID: 11876260
Don't think ASP will do that...
0
 
LVL 31

Expert Comment

by:alorentz
ID: 11876268
Using "on error resume next" will not work in this situation either.  however this error should not stop the script, it will effect SMTP and badmail, but the script should continue.
0
 
LVL 31

Accepted Solution

by:
alorentz earned 100 total points
ID: 11876277
CDO script doesn't care if the email doesn't exist.  SMTP will just send to badmail, and may send Admin email to your domain account.  But ASP should run through all names in DB.
0
 

Author Comment

by:bobamatics
ID: 11876335
Ok, I tried to mail to an address I know doesn't exist, and you're right, it sends it anyway.

But then I have no idea why it halts at certain addresses. Seems there not much I can do about it then?
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 31

Expert Comment

by:alorentz
ID: 11876417
No idea why it would halt?

Maybe on nulls, or if there's a space in the address.  But if there anything else in it "jdoe@jdoe.com", "sss", whatever, it will not stop the script.  Check for nulls or spaces in the email.
0
 

Author Comment

by:bobamatics
ID: 11876517
That's the thing, I ran the script four times with slight modifications inbetween and got the error message. Then I checked my inbox and saw four "Undelivered Mail Returned to Sender" mails.

I do trim(strEmail) when I put in the address in the database...so it should send them. Is there a limit on how many requests a mail server will accept at once or something? I use my ISP:s SMTP server and try to loop 30 mails in the execution of the page.
0
 
LVL 31

Expert Comment

by:alorentz
ID: 11876546
Yes, they may block the amount of email that can be sent...to prevent spamming.  Many ISP's do check for this sort of thing.

However, TRIM won't work on somthing like this "jdoe@ jdoe.com".  That will kill the script because of the internal space.

But, most likely this is a problem because you ISp is not allowing all those emails at the same time.  MAy want to limit to 10 or so.
0
 

Author Comment

by:bobamatics
ID: 11876581
Now I Response.Wrote the id:s after the mails had been sent and checked where it stopped. And it stopped mostly on faulty addresses, like whatever@hotmail.co (isn't co a top domain?) and _blah_@domain.com where _ isn't allowed as a starting character. But liiiinda@hotmail.com wasn't accepted. Very strange.

Oh well, I've got most of the mails away now, and your answer was correct so have the points and thanks for your time and help :)
0
 
LVL 31

Expert Comment

by:alorentz
ID: 11876637
Good luck!
0
 

Author Comment

by:bobamatics
ID: 11876652
Isn't it strange that it halts on michel_kt@hotail.com if it doesn't know that doesn't exists? Just wondering...it clearly looks like a misspelling to me.
0
 
LVL 31

Expert Comment

by:alorentz
ID: 11876684
I still don't know why the script would stop, but CDO may validate on domain name. MS may have incorporated this functionality into the new CDOSYS component.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

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 demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

708 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

18 Experts available now in Live!

Get 1:1 Help Now