Re: Email Verfication Regular Expression

Поиск
Список
Период
Сортировка
От Cristian Prieto
Тема Re: Email Verfication Regular Expression
Дата
Msg-id 039b01c5b4a1$74dde280$6500a8c0@gt.ClickDiario.local
обсуждение исходный текст
Ответ на Email Verfication Regular Expression  (Brad Nicholson <bnichols@ca.afilias.info>)
Ответы Re: Email Verfication Regular Expression  (merlyn@stonehenge.com (Randal L. Schwartz))
Re: Email Verfication Regular Expression  (Stephane Bortzmeyer <bortzmeyer@nic.fr>)
Список pgsql-general
Well, I guess this could be a hard-expensive way to do it but I've done this
little Stored Function, it doesn't use a regular expresion (you could pass
your email first to one to check it out I guess).

#include "postgres.h"
#include "fmgr.h"
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>

PG_FUNCTION_INFO_V1(digmx);

Datum
digmx(PG_FUNCTION_ARGS)
{
 int res;
 char *name;
 char answer[1024];
 text *arg;

 arg = PG_GETARG_TEXT_P(0);

 res = res_init();
 if(res != 0) {
  // Aki reporto un error
 }
 name = (char *) palloc(VARSIZE(arg)-VARHDRSZ);
 strcpy(name, VARDATA(arg));

 res = res_query(name, C_IN, T_MX, answer, sizeof(answer));

 if(res == -1) {
  PG_RETURN_BOOL(false);
 } else {
  // Aki imprimimos lo que debe escupir
  PG_RETURN_BOOL(true);
 }
}

You can pass the domain to that function and It would check using resolv if
the domains has an mx entry in the nameserver. I guess it is a little slow
(it was not thinking to use it for speed, but I accept suggestions for it!)
but I think it is enough easy and it could be usefull for somebody.

mydb# SELECT digmx('hotmail.com');
digmx
------
t
(1 row)

mydb# SELECT digmx('hotmail.co');
digmx
------
f
(1 row)

I know, it could be a very dumb to check the domain, but I consider myself
as a totally newbie database/unix/programmer.

Thanks a lot!

PD: Please, I accept suggestion to improve this function.


В списке pgsql-general по дате отправления:

Предыдущее
От: Matthew Peter
Дата:
Сообщение: Re: back references using regex
Следующее
От: Peter Fein
Дата:
Сообщение: Re: back references using regex