Mailing List Archive

qmail-smtpd: Selectively bcc'ing relayed email
I have a server X which is one of many using my qmail server as its smtp
relay (using a ip based whitelist; I'm running qmail-smtpd under
tcpserver). X does not provide a way to add a BCC address to emails that it
sends out.

Would it be possible to catch emails from X and add a BCC header or forward
to a certain address?

I looked at QUEUE_EXTRA and recordio, but they keep a copy of *all*
incoming and outgoing mail messages. (From the FAQ).

I looked at qmail-inject, but realized it's outside of the path that mail
being relayed by SMTP from another host take (PIC.relaygood).

I've been puzzling over the faq question, "How do I fix up messages from
dumb clients?" Wondering if that is the solution to my mess?
It would seem to push qmail-inject back into the path. If so, how would I
modify the string to be inserted into .qmail-fixup-default? And would it
cause trouble for all of the other servers using my qmail server as their
relay (as RELAYCLIENT is set to "" for them)?

Much thanks,
Mike Robison
Re: qmail-smtpd: Selectively bcc'ing relayed email [ In reply to ]
On 19.02.2014 16:06, Mike Robison wrote:

> Would it be possible to catch emails from X and add a BCC header or forward
> to a certain address?

http://www.inter7.com/?page=qmailtap

Regards
--
Robert Sander
gurubert.de
Re: qmail-smtpd: Selectively bcc'ing relayed email [ In reply to ]
Hi,

QUEUE_EXTRA allows to plug-in a script which can do what you want.

With my Spamcontrol patch, I ship a script called qmail-queue.scan which
can be customized to your needs.

Usually, within the script, AV-scanners and Spamassassin are called
(triggered by the domain of the recipient).
However you can add any logic. In addition, a mechanism is provided to
forward the mail to other recipients, which is actually equivalent to add a
BCC while sending the mail.

Check <http://www.fehcom.de/qmail/spamcontrol/README_spamcontrol.html>

and perhaps download the patch and extract the script.

However, be cautios: Spamcontrol adds more Return-Codes to qmail-queue.
There is no need to install Spamcontrol, though.

regards.
--eh.

--On 19. Februar 2014 10:06:41 -0500 Mike Robison <mrobison@wts.edu> wrote:

>
> I have a server X which is one of many using my qmail server as its smtp
> relay (using a ip based whitelist; I'm running qmail-smtpd under
> tcpserver). X does not provide a way to add a BCC address to emails that
> it
> sends out.
>
> Would it be possible to catch emails from X and add a BCC header or
> forward
> to a certain address?
>
> I looked at QUEUE_EXTRA and recordio, but they keep a copy of *all*
> incoming and outgoing mail messages. (From the FAQ).
>
> I looked at qmail-inject, but realized it's outside of the path that mail
> being relayed by SMTP from another host take (PIC.relaygood).
>
> I've been puzzling over the faq question, "How do I fix up messages from
> dumb clients?" Wondering if that is the solution to my mess?
> It would seem to push qmail-inject back into the path. If so, how would I
> modify the string to be inserted into .qmail-fixup-default? And would it
> cause trouble for all of the other servers using my qmail server as their
> relay (as RELAYCLIENT is set to "" for them)?
>
> Much thanks,
> Mike Robison



--
Dr. Erwin Hoffmann | FEHCom | http://www.fehcom.de/ | PGP-Key-Id: 7E4034BE
Re: qmail-smtpd: Selectively bcc'ing relayed email [ In reply to ]
On Wednesday, February 19 at 10:06 AM, quoth Mike Robison:
> Would it be possible to catch emails from X and add a BCC header or
> forward to a certain address?

Absolutely. Here's the thing about qmail that so few people seem to
really understand: it's a framework, and there's almost always
multiple ways of doing the same thing.

You can catch emails at multiple points:
1. During the SMTP conversation
(by putting a wrapper around, or modifying, qmail-smtpd)
2. Before they enter the mail queue
(by putting a wrapper around, or modifying, qmail-queue)
3. Before they exit the mail queue
(by modifying qmail-send or configuring the mail routing)
4. Before they are relayed to a remote server
(by putting a wrapper around, or modifying, qmail-remote)

If you want to add an extra recipient (not necessarily add a BCC
header), the simplest place to do it is somewhere before the routing
decision gets made, i.e. point #1 or #2, but technically any of these
options are possible.

These wrappers could be anything from shell scripts to C programs, and
you certainly don't HAVE to recompile qmail (though recompiling may
provide the most direct or highest performance option).

> I looked at QUEUE_EXTRA and recordio, but they keep a copy of *all*
> incoming and outgoing mail messages. (From the FAQ).

That's one way to do it (it's a form of #2, from my list). Just
because you CAN save-off a copy of ALL messages doesn't mean you HAVE
to. You can put filters (e.g. procmail or maildrop or even something
much simpler) in the ~alias/.qmail-log file and only save off a
limited subset. This is how the qmailtap program (available from
inter7) works, and it gives you precisely that kind of a filter.

> I looked at qmail-inject, but realized it's outside of the path that
> mail being relayed by SMTP from another host take (PIC.relaygood).

Sure. That's a variant of option #1 that only applies to
locally-sourced emails. So... what about qmail-smtpd?

Or, consider this: the common touchpoint between both qmail-inject and
qmail-smtpd is the qmail queue (#2). Unless you've written your own
tool for injecting into the queue (in which case, why are you asking
this question?!?), the qmail-queue program is the most straightforward
way of intercepting all messages before they enter the queue. This is
the option that Dr. Hoffmann suggested.

> I've been puzzling over the faq question, "How do I fix up messages
> from dumb clients?" Wondering if that is the solution to my mess? It
> would seem to push qmail-inject back into the path. If so, how would
> I modify the string to be inserted into .qmail-fixup-default? And
> would it cause trouble for all of the other servers using my qmail
> server as their relay (as RELAYCLIENT is set to "" for them)?

Sure, you could do that; it's option #3 or #4, depending on how you
look at it. Personally, I think that's a little on the overly
complicated side, but it's really all about what makes the most sense
to you and meets your needs (in terms of maintainability and
performance, as well as function).

I realize I'm not giving you a specific answer; I'm trying to make you
think about the problem the right way.

Hope that helps,

~Kyle
--
If I had been married earlier in life, I wouldn't have seen the double
helix. I would have been taking care of the kids on Saturday. On the
other hand, I was lonely a lot of the time.
-- James Watson