• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 515
  • Last Modified:

CDO Message + trap invalid mail addresses

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
bobamatics
Asked:
bobamatics
  • 8
  • 5
1 Solution
 
alorentzCommented:
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
 
bobamaticsAuthor Commented:
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
 
alorentzCommented:
Don't think ASP will do that...
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
alorentzCommented:
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
 
alorentzCommented:
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
 
bobamaticsAuthor Commented:
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
 
alorentzCommented:
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
 
bobamaticsAuthor Commented:
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
 
alorentzCommented:
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
 
bobamaticsAuthor Commented:
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
 
alorentzCommented:
Good luck!
0
 
bobamaticsAuthor Commented:
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
 
alorentzCommented:
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 8
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now