bug-mailfromd


Search for: Advanced

Re: [Bug-mailfromd] srs (sender rewrite)


Marc <Marc@xxxxxxxxxxxxxxxxx> ha escrit:

> rcpt_host:shaflyn.com. rcpt_mailer:esmtp

That's how it is described in your mailertable.

> I was wondering if there is a macro available that has the value
> mail.shaflyn.com or even better 157.230.202.57?

No, there is not.  And perhaps there's no need to: you can always
obtain it yourself.

1. To operate on MX names:

  if $rcpt_mailer == 'esmtp'
    set mxd dns_query(DNS_TYPE_MX, $rcpt_host)
    if mxd >= 0
      loop for set i 0,
	   while i < dns_reply_count(mxd),
           set i i + 1
      do
	DTRT(dns_reply_string(mxd, i))
      done
      dns_reply_release(mxd )
    fi
  fi

2. To operate on MX IP addresses:

  if $rcpt_mailer == 'esmtp'
    set mxd dns_query(DNS_TYPE_MX, $rcpt_host)
    if mxd >= 0
      loop for set i 0,
	   while i < dns_reply_count(mxd),
           set i i + 1
      do
	set ipd dns_query(DNS_TYPE_A, dns_reply_string(mxd, i))
	loop for set j 0,
	     while j < dns_reply_count(ipd),
	     set j j + 1
	do
	  DTRT(dns_reply_string(ipd, j))
	done
	dns_reply_release(ipd)
      done
      dns_reply_release(mxd)
    fi
  fi

In both cases, DTRT is your function, which takes a string as its
argument (MX hostname in example 1 and MX IP address in example 2).
See the docs (section 5.24.1 dns_query) for details.

> PS. Do you have by any chance a link to an up to date online manual of
> sendmail (not pdf). I always tend to find outdated pages, and never a
> complete overview of these macro's.

Just get a suitable release tarball from https://ftp.sendmail.org/,
untar it, change to the source top-level directory, run

  nroff -me ./doc/op/op.me | less

and enjoy your reading.

That being said, it is rather hard to get an "outdated" doc on sendmail,
given that its codebase is incredibly stable and any changes that occur
between the releases are relatively insignificant. Whichever version you
get (since 8.13.7, at least), you will get a sufficiently up-to-date
docs.

Regards,
Sergey