sending mail from a milter filter
am 15.09.2007 02:04:40 von jerrro
Hello,
I have two questions, any help would be appreciated:
I am interested in sending an e-mail as a reply back to an e-mail
which was processed using a Milter e-mail.
What would be the best way to do that? I assume that pipe opening
sendmail and sending the e-mail is not the best way to do that,
especially if there is a heavy load on the server. Maybe there is a
shortcut with milter filters?
Also, what would be the quickest way to send an e-mail using sendmail
from a C++ application in general (not necessarily a filter)? Is popen
the best way?
Thanks.
Jerr.
Re: sending mail from a milter filter
am 15.09.2007 23:39:13 von DFS
jerrro@gmail.com wrote:
> I am interested in sending an e-mail as a reply back to an e-mail
> which was processed using a Milter e-mail.
> What would be the best way to do that? I assume that pipe opening
> sendmail and sending the e-mail is not the best way to do that,
> especially if there is a heavy load on the server.
It's a reasonable way if you want to compose a brand new mail (rather than
just adding a recipient to the original mail.)
However, you may want to invoke Sendmail in deferred mode (-odd
command-line option) so that the mail just gets queued and then
processed in the next queue run. That will help reduce the likelihood
of a spike in the number of running milters.
> Also, what would be the quickest way to send an e-mail using sendmail
> from a C++ application in general (not necessarily a filter)? Is popen
> the best way?
popen() if used correctly is reasonable, but it's very hard to use
popen() safely and correctly. You should read "Advanced Programming
in the UNIX Environment" by Rich Stevens; he discusses the UNIX
process-control and IPC primitives like fork(), exec(), pipe() and
wait() in detail. (The problem with popen() is that it feeds its argument
to the shell, so shell metacharacters can cause trouble. forking and
execing bypasses the shell completely and avoids the problem.)
Regards,
David.
Re: sending mail from a milter filter
am 08.10.2007 02:21:17 von Joe Maimon
On Sep 15, 5:39 pm, "David F. Skoll" wrote:
> jer...@gmail.com wrote:
> > I am interested in sending an e-mail as a reply back to an e-mail
> > which was processed using a Milter e-mail.
> > What would be the best way to do that? I assume that pipe opening
> > sendmail and sending the e-mail is not the best way to do that,
> > especially if there is a heavy load on the server.
>
> It's a reasonable way if you want to compose a brand new mail (rather than
> just adding a recipient to the original mail.)
>
> However, you may want to invoke Sendmail in deferred mode (-odd
> command-line option) so that the mail just gets queued and then
> processed in the next queue run. That will help reduce the likelihood
> of a spike in the number of running milters.
>
> > Also, what would be the quickest way to send an e-mail using sendmail
> > from a C++ application in general (not necessarily a filter)? Is popen
> > the best way?
>
> popen() if used correctly is reasonable, but it's very hard to use
> popen() safely and correctly. You should read "Advanced Programming
> in the UNIX Environment" by Rich Stevens; he discusses the UNIX
> process-control and IPC primitives like fork(), exec(), pipe() and
> wait() in detail. (The problem with popen() is that it feeds its argument
> to the shell, so shell metacharacters can cause trouble. forking and
> execing bypasses the shell completely and avoids the problem.)
>
> Regards,
>
> David.
clamav-milter and spamass-milter both contain examples of this among
others
http://www.jmaimon.com/sendmail/milters