This is a discussion on reverse name lookups within the alt.comp.mail.qmail forums, part of the Mail Servers and Related category; Hi folks, Simple question... how to do a reverse name lookups with qmail ? This is for return mail / bounce from ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
On 20 Feb 2004 01:22:31 -0800, Paul Darius <paul@spc.co.id> may have written:
> > Simple question... how to do a reverse name lookups with qmail ? > > This is for return mail / bounce from system to sender. I am not sure what you mean by this? qmail itself should never need to do a reverse lookup. tcpserver will do reverse lookups of incoming connections and set an environment variables called TCPREMOTEHOST. What problem are you trying to solve? -- Brian T Glenn delink.net Internet Services |
|
|||
|
> I am not sure what you mean by this? qmail itself should never need to
> do a reverse lookup. tcpserver will do reverse lookups of incoming > connections and set an environment variables called TCPREMOTEHOST. > > What problem are you trying to solve? To reject emails from non existing domain. We received a lot of emails from non existing domain to non existing address @ our domains. Regards PD |
|
|||
|
On 22 Feb 2004 19:19:24 -0800, Paul Darius <paul@spc.co.id> wrote:
>> I am not sure what you mean by this? qmail itself should never need to >> do a reverse lookup. tcpserver will do reverse lookups of incoming >> connections and set an environment variables called TCPREMOTEHOST. >> >> What problem are you trying to solve? > > To reject emails from non existing domain. We received a lot of emails > from non existing domain to non existing address @ our domains. > > Regards > > PD this is patch against netqmail-1.05. if file control/mfcheck or env var MFCHECK has number 0, no checks are done. --- netqmail-1.05/qmail-smtpd.c.bak 2004-02-09 19:38:08.000000000 +0200 +++ netqmail-1.05/qmail-smtpd.c 2004-02-09 20:00:52.000000000 +0200 @@ -23,9 +23,11 @@ #include "timeoutread.h" #include "timeoutwrite.h" #include "commands.h" +#include "dns.h" #define MAXHOPS 100 unsigned int databytes = 0; +unsigned int mfchk = 0; int timeout = 1200; int safewrite(fd,buf,len) int fd; char *buf; int len; @@ -50,6 +52,8 @@ void die_ipme() { out("421 unable to fig void straynewline() { out("451 See http://pobox.com/~djb/docs/smtplf.html.\r\n"); flush(); _exit(1); } void err_bmf() { out("553 sorry, your envelope sender is in my badmailfrom list (#5.7.1)\r\n"); } +void err_hmf() { out("553 sorry, your envelope sender domain must exist (#5.1.8)\r\n"); } +void err_smf() { out("451 temporary DNS error while resolving envelope sender domain (#4.7.0)\r\n"); } void err_nogateway() { out("553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)\r\n"); } void err_unimpl(arg) char *arg; { out("502 unimplemented (#5.5.1)\r\n"); } void err_syntax() { out("555 syntax error (#5.5.4)\r\n"); } @@ -112,6 +116,10 @@ void setup() if (rcpthosts_init() == -1) die_control(); + if (control_readint(&mfchk, "control/mfcheck") == -1) die_control(); + x = env_get("MFCHECK"); + if (x) { if (scan_ulong(x, &u)) mfchk = u; } + bmfok = control_readfile(&bmf,"control/badmailfrom",0); if (bmfok == -1) die_control(); if (bmfok) @@ -208,6 +216,27 @@ int bmfcheck() return 0; } +int mfcheck(ips) +int *ips; +{ + static stralloc sa_mf = {0}; + static ipalloc ia_mf = {0}; + int j; + + if (ips) *ips = 0; + if (!mfchk || (addr.len == 1)) return 0; + j = byte_rchr(addr.s, addr.len, '@') + 1; + if (j < addr.len) { + if (!stralloc_copys(&sa_mf, addr.s + j)) die_nomem(); + j = dns_mxip(&ia_mf, &sa_mf, 1); + if (ips) *ips = ia_mf.len; + if ((j == 0) && (ia_mf.len == 0)) return DNS_HARD; + return j; + } else { + return 0; + } +} + int addrallowed() { int r; @@ -239,8 +268,24 @@ void smtp_rset(arg) char *arg; } void smtp_mail(arg) char *arg; { + int ips; + if (!addrparse(arg)) { err_syntax(); return; } flagbarf = bmfcheck(); + switch(mfcheck(&ips)) { + case DNS_HARD: + err_hmf(); + return; + case 1: + /* resolved at least one IP? */ + if (ips > 0) break; + case DNS_SOFT: + case DNS_MEM: + err_smf(); + return; + default: + break; + } seenmail = 1; if (!stralloc_copys(&rcptto,"")) die_nomem(); if (!stralloc_copys(&mailfrom,addr.s)) die_nomem(); -- Safari - y7pt9001@sneakemail.com.gov.invalid - Reply-To to reply (remove 'ies') http://eth1.promisc.us/aestrap.html |
|
|||
|
> > To reject emails from non existing domain. We received a lot of emails
> > from non existing domain to non existing address @ our domains. > > > > Regards > > > > PD > > this is patch against netqmail-1.05. > if file control/mfcheck or env var MFCHECK has number 0, > no checks are done. > Could you please to advice an example of : + MFCHECK env and where to put ? + control/mfcheck file ? Regards PD |
|
|||
|
On 24 Feb 2004 01:51:17 -0800, Paul Darius <paul@spc.co.id> wrote:
>> > To reject emails from non existing domain. We received a lot of emails >> > from non existing domain to non existing address @ our domains. >> > >> > Regards >> > >> > PD >> >> this is patch against netqmail-1.05. >> if file control/mfcheck or env var MFCHECK has number 0, >> no checks are done. >> > Could you please to advice an example of : > + MFCHECK env and where to put ? well well, if you use tcpserver, -x option specifies the cdb file to use, here example line for tcprules: 10.20.30.40:allow,RELAYCLIENT="",MFCHECK="0" docs are here http://cr.yp.to/ucspi-tcp.html > + control/mfcheck file ? echo 1 > /var/qmail/control/mfcheck (make sure permissions are OK) MFCHECK env var overrides control/mfcheck. > Regards > > PD -- Safari - y7pt9001@sneakemail.com.gov.invalid - Reply-To to reply (remove 'ies') http://eth1.promisc.us/aestrap.html |