[twsocket] How to validate an e-mail?

Davie smatters@smatters.com
Thu, 01 Jun 2000 18:53:41 -0500


Isn't it true that it may not bounce back right away if the destination server
is currently offline? Or maybe if it is online isn't it possible that it WILL
bounce back even though it IS valid beaause of maybe mailbox full?

Davie

Stephen Williams wrote:

> > Is there any way to validate an e-mail adress?
> >
> > something like the demo program "httpchk".
>
> If you just want to validate that the email address is of the correct
> syntax, then this function will help.
>
> { Returns True if the input matches the mask.  Uses a recursive method
>   to perform the check.  }
> function MatchMask(Input, Mask: PChar): Boolean;
> begin
>   if StrComp(Hostmask, '*') = 0 then
>     Result := True
>   else if (Address^ = #0) and (Hostmask^ <> #0) then
>     Result := False
>   else if (Address^ = #0) then
>     Result := True
>   else
>     case Hostmask^ of
>       '*':
>             if MatchHostmask(Address, Hostmask + 1) then
>               Result := True
>             else
>               Result := MatchHostmask(Address + 1, Hostmask);
>       '?':
>             Result := MatchHostmask(Address + 1, Hostmask + 1);
>     else
>       if Address^ = Hostmask^ then
>         Result := MatchHostmask(Address + 1, Hostmask + 1)
>       else
>         Result := False;
>     end;
> end;
>
> Call this function with the email address and a mask of '*@*.*', such as
>
>   if MatchMask(PChar(EmailEdit.Text), '*@*.*') then
>   begin
>     ...
>   end;
>
> If you want to check that the email address actually exists, then the only
> way to do that is to actually send an email to that address.  If it bounces,
> it doesn't exist.
>
> Steve 'Sly' Williams
> IT Development
> Cable & Wireless Optus Outsourcing Services
> swilliams@fm.optus.net.au
> ------------------------------------------------------------
> "I read somewhere that 77 per cent of all the mentally ill live in poverty.
> Actually, I'm more intrigued by the 23 per cent who are apparently doing
> quite well for themselves."
> ------------------------------------------------------------
>
> _______________________________________________
> TWSocket mailing list [http://elists.org/mailman/listinfo/twsocket]
> Visit our website at http://www.rtfm.be/fpiette/indexuk.htm