Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Manage pending messages in sendmail queue

37 views
Skip to first unread message

sadsjon

unread,
Apr 1, 2008, 8:00:17 AM4/1/08
to
I have spent the last couple of days trawling for some ideas on this
one so I am getting desperate now.

I run sendmail to route mail to a number of customer domains.

Just recently we had two customer servers down.

Whilst waiting for repairs they asked whether they could review their
mails online.

I had to say no because I don't have a clue how go about doing this.

I can't mutt the mails from the mail queue because they are just text,
I can't use Squirrelmail because these are not in anyones mailbox.

ISP's can do this sort of thing, does anyone have any insight into how
I might achieve something of use, either converting and emailing items
from the queue to a secondary mail address or give my customers access
to their queued mail via a browser.

Any suggestion at all is likely to be better than what I have got so
far so I would really appreciate some help on this.

Many thanks all,

jON

Andrzej Adam Filip

unread,
Apr 1, 2008, 8:42:48 AM4/1/08
to
sadsjon <jon.r...@sads.com> wrote:

You can adapt "delivery to shared mailbox" recipes.
It makes sendmail insert "RCPT TO:" info into message headers
(e.g. into X-Envelope-To: loved by fetchmail). You can deliver
such messages to two mailboxes one for "inspection" the second
for later "normal" delivery.

See the link below for more hints:
http://ftp.nakedape.cc/pub/anfi.homeunix.net/sendmail/sharedmailbox.html
It is a copy of anfi.homeunix.net page; my site anfi.homeunix.net is no
longer available online - I have lost control over the domain.

--
[pl>en: Andrew] Andrzej Adam Filip an...@xl.wp.pl sip:896...@fwd.pulver.com
Open-Sendmail: http://open-sendmail.sourceforge.net/
Even if you persuade me, you won't persuade me.
-- Aristophanes

sadsjon

unread,
Apr 4, 2008, 3:49:48 AM4/4/08
to
The link refers to procmail. Do I have to install procmail Andrzej or
do I need to adapt this to sendmail syntax? I haven't a clue about
procmail but I will research if I need to.

I am already using milters and check_local and some code posted here a
couple of years ago that allows me to do clever things with
virtusertable.

I am beginning to get nervous about just how bespoke my systems are -
nightmare for replicating servers ...

I was wondering whether maildrop could help me do what I want - I have
played with SquirrelMail and can create IMAP emails quite easy from
scripts - would that be a better idea or would your procmail solution
be more elegant?

Many thanks for your time Andrzej ,

jON

>
> You can adapt "delivery to shared mailbox" recipes.
> It makes sendmail insert "RCPT TO:" info into message headers
> (e.g. into X-Envelope-To: loved by fetchmail). You can deliver
> such messages to two mailboxes one for "inspection" the second
> for later "normal" delivery.
>
> See the link below for more hints:
>  http://ftp.nakedape.cc/pub/anfi.homeunix.net/sendmail/sharedmailbox.html
> It is a copy of anfi.homeunix.net page; my site anfi.homeunix.net is no
> longer available online - I have lost control over the domain.
>
> --

> [pl>en: Andrew] Andrzej Adam Filip a...@xl.wp.pl sip:896...@fwd.pulver.com


> Open-Sendmail:http://open-sendmail.sourceforge.net/
> Even if you persuade me, you won't persuade me.

>   -- Aristophanes- Hide quoted text -
>
> - Show quoted text -

sadsjon

unread,
Apr 4, 2008, 12:34:10 PM4/4/08
to
Also Andrzej, this worries me a little ...

"Make sure that shared-mailbox.domain IS NOT a local email domain. To
get list of local domains ..."

These are domains for which I hold backup MX and therefore ARE local
domains. I have Cw entries in sendmail.mc for them.

So does this mean that I can't use your procmail route?

jON

Andrzej Adam Filip

unread,
Apr 4, 2008, 1:26:57 PM4/4/08
to
sadsjon <jon.r...@sads.com> wrote:
>> See the link below for more hints:
>>  http://ftp.nakedape.cc/pub/anfi.homeunix.net/sendmail/sharedmailbox.html
>
> Also Andrzej, this worries me a little ...
>
> "Make sure that shared-mailbox.domain IS NOT a local email domain. To
> get list of local domains ..."
>
> These are domains for which I hold backup MX and therefore ARE local
> domains. I have Cw entries in sendmail.mc for them.

Why?! It is not required.
All you need for "dumb" secondary MX (pre spam era standard) is the
following access db entry:

to:example.com RELAY

Even if you deploy rejecting invalid email addresses (addresses primary
MX rejects) then the domain does not have to be local.

> So does this mean that I can't use your procmail route?

Tell a little (2-3 more sentences) about configuration you use.

--
[pl>en: Andrew] Andrzej Adam Filip an...@xl.wp.pl

Open-Sendmail: http://open-sendmail.sourceforge.net/
All the existing 2.0.x kernels are to buggy for 2.1.x to be the
main goal.
-- Alan Cox

sadsjon

unread,
Apr 4, 2008, 3:02:11 PM4/4/08
to
Sorry Andrzej, I have some virtusertable mappings that I have just -
got used- to always using. I have been working on this all afternoon
and you are absolutely correct, there is no need.

I have now set up a standard relay for a domain that I own, there is
NO Cw record, I have the relay-domain entry and mailertable points to
an IP that does not host SMTP so the mail stays in the queue. I have
successfully reproduced the scenario when a customer server is down.

I believe I have worked out how your instructions work.

Issuing "sendmail -bv -d60.1 $1" for my domain tells me that
the mail will be passed to my script (mydomainname.co.uk.rc)

and I have a mailbox called "jon" which I can log into via
Squirrelmail (Imap)

Now the mail comes into the queue, syslog tells me it was delivered
to

relay=/etc/procmailrcs/mydomain.co.uk.rc

but the mail does not remain in the queue and the mailbox does not
receive the mail. It dissapears.

I have NOT used the PGP signed files on the web page that I am
referring to that you wrote (I don't really know what to do with
them), I have "chmod +x" my .rc script and the .pl script.

I have checked perl which tells me :

This is perl, v5.8.8 built for i486-linux-gnu-thread-multi

I don't seem to be able to find any log that tells me where my mail
has gone.

I feel I am very close ... please forgive my ignorance, I am not a
seasoned pro with this stuff.

many thanks,

jON

Andrzej Adam Filip

unread,
Apr 5, 2008, 7:54:31 AM4/5/08
to
sadsjon <jon.r...@sads.com> wrote:

> Sorry Andrzej, I have some virtusertable mappings that I have just -
> got used- to always using. I have been working on this all afternoon
> and you are absolutely correct, there is no need.
>
> I have now set up a standard relay for a domain that I own, there is
> NO Cw record, I have the relay-domain entry and mailertable points to
> an IP that does not host SMTP so the mail stays in the queue. I have
> successfully reproduced the scenario when a customer server is down.
>
> I believe I have worked out how your instructions work.
>
> Issuing "sendmail -bv -d60.1 $1" for my domain tells me that
> the mail will be passed to my script (mydomainname.co.uk.rc)
>
> and I have a mailbox called "jon" which I can log into via
> Squirrelmail (Imap)
>
> Now the mail comes into the queue, syslog tells me it was delivered
> to
>
> relay=/etc/procmailrcs/mydomain.co.uk.rc
>
> but the mail does not remain in the queue and the mailbox does not
> receive the mail. It dissapears.

Add debugging to the procmail script (at the very begin).

LOGFILE=_path_to_log_file_you_want_to_get_
VERBOSE=yes
LOGABSTRACT=all


> I have NOT used the PGP signed files on the web page that I am
> referring to that you wrote (I don't really know what to do with
> them), I have "chmod +x" my .rc script and the .pl script.
>
> I have checked perl which tells me :
>
> This is perl, v5.8.8 built for i486-linux-gnu-thread-multi
>
> I don't seem to be able to find any log that tells me where my mail
> has gone.
>
> I feel I am very close ... please forgive my ignorance, I am not a
> seasoned pro with this stuff.

I remember "a few plus" "simple *AFTER*" "traps" I have fallen into when
developing/debugging the above recipe :-)

--
[pl>en: Andrew] Andrzej Adam Filip an...@xl.wp.pl
Open-Sendmail: http://open-sendmail.sourceforge.net/

Walk softly and carry a big stick.
-- Theodore Roosevelt

sadsjon

unread,
Apr 5, 2008, 8:58:32 AM4/5/08
to
I have worked out what is going on. The mail is going to the standard
mail system and not to Maildir that I am using.

All my mails are sitting there waiting to be read.

According to the docs, I need to add a "\" after the mailbox name to
trigger a Maildir delivery but it doesn't seem to work if i add that
to my RC script, it says user doesn't exist ...???

Also, the mail is only delivered to the mailbox, it should be queued
for my "down" server as well.

But its a thrill to see something working !!!

Do you have any idea on the above Andrzej?

jON

Kees Theunissen

unread,
Apr 5, 2008, 2:36:49 PM4/5/08
to
sadsjon wrote:
> I have worked out what is going on. The mail is going to the standard
> mail system and not to Maildir that I am using.
>
> All my mails are sitting there waiting to be read.
>
> According to the docs, I need to add a "\" after the mailbox name to
> trigger a Maildir delivery but it doesn't seem to work if i add that
> to my RC script, it says user doesn't exist ...???

My procmailrc(5) manpage says it has to be a "/".

Regards,

Kees.

--
Kees Theunissen.

Andrzej Adam Filip

unread,
Apr 5, 2008, 5:47:28 PM4/5/08
to
sadsjon <jon.r...@sads.com> wrote:

> I have worked out what is going on. The mail is going to the standard
> mail system and not to Maildir that I am using.
>
> All my mails are sitting there waiting to be read.
>
> According to the docs, I need to add a "\" after the mailbox name to
> trigger a Maildir delivery but it doesn't seem to work if i add that
> to my RC script, it says user doesn't exist ...???

Do you use it on unix/linux?
YES => it should be trailing "/"

Have you checked that the maildir directory you specify in procmail
script does exist?

> Also, the mail is only delivered to the mailbox, it should be queued
> for my "down" server as well.

You can use ":0 c" recipes in your procmail script.
They conduct "delivery of a copy".

You can use the lines below to get envelope sender in $SENDER (formatted
as -f command line option of sendmail likes) and list of recipients in "$@".
###################################
SENDER="$1"
SHIFT=1

# rewrite "" into "<>"
:0
* SENDER ?? ^^^^
{ SENDER="<>" }
###################################

Have you considered running fetchmail on primary MX to fetch "shared
mailbox" filled by secondary MX?

It is a "security risk" on some installation, it is an extra advantage
on others (mainly smaller sites) e.g. by allow primary MX to get messages
from secondary MX even using dialup link in case of primary link outages

> But its a thrill to see something working !!!

> [...]

--
[pl>en: Andrew] Andrzej Adam Filip an...@xl.wp.pl
Open-Sendmail: http://open-sendmail.sourceforge.net/

I love children. Especially when they cry -- for then someone takes them away.
-- Nancy Mitford

sadsjon

unread,
Apr 6, 2008, 3:29:12 AM4/6/08
to
>
> Do you use it on unix/linux?
> YES => it should be trailing "/"
>

I am using Debian Linux

I have tried adding the trailing "/" to my .rc script,
adding MAILDIR=$HOME/.maildir to my .rc script,
adding the same entry to my users ./.procmailrc script,
putting the entry in my .rc of :

MAILBOX=jon
MAILBOX=jon/
MAILBOX="jon/"
MAILBOX="/home/jon"
MAILBOX="/home/jon/Maildir"

I still get my email delivered to my mbox and not to Maildir.

I have NO /etc/procmailrc script btw.

> Have you checked that the maildir directory you specify in procmail
> script does exist?
>

It does, I am logged into it using Squirrelmail and have sent items
from that and also cobbled together an email and stuck it into the
mailbox manually.


> You can use ":0 c" recipes in your procmail script.
> They conduct "delivery of a copy".
>
> You can use the lines below to get envelope sender in $SENDER (formatted
> as -f command line option of sendmail likes) and list of recipients in "$@".
> ###################################
> SENDER="$1"
> SHIFT=1
>
> # rewrite "" into "<>"
> :0
> * SENDER ?? ^^^^
> { SENDER="<>" }
> ###################################
>

I thought the code in your original URL caused sendmail to deliver to
the sendmail queue and to a seperate mailbox as well.

Do I have to set up both a ":0 c" in my .rc script as well as the
above recpient list breakout. I don't want to break out the recipients
really. I just want the item in the sendmail queue to be copied to a
mailbox for my customer to review. I am quite happy for them to manage
this mailbox whilst there server is offline using just one email
address. Generally these are small offices with a few people. Only the
Manager of the office needs to be able to deal with business mails and
review whats there.


> Have you considered running fetchmail on primary MX to fetch "shared
> mailbox" filled by secondary MX?
>

I have to say that I and baffled by all the options. All I am after is
a simple mechanism whereby I can allow my customers to see what the
incoming mails are so they can act on them during the business day
when their email is down. I had even started working on placing items
directly in the Maildir directory by using awk to create a new header
and then head off looking for a decoder for decoding MIME.

I honestly don't know whether fetchmail would work ... or be
better ... but as I have procmail so close I am wondering whether I
should stick with it for now. The fetchmail doc's don't reallly tell
me what I need to know on how to use and configure it, it seems even
more baffling than procmail.

If you say that fetchmail will be simpler then I will switch my
concentration to that, you are the expert and I have to admit that I
am far from one!!

Although rereading the above, are you saying that I should ALWAYS
deliver from secondary MX to Primary MX via fetchmail? In which case
this would not work as some of these domains we are the primary MX and
there is no secondary.

jON

sadsjon

unread,
Apr 6, 2008, 3:32:57 AM4/6/08
to
Update ...

I reviewied google for Maildir /etc/procmailrc settings regarding
domains.

I added the file and added entry

DEFAULT=$HOME/Maildir/

and mail is now poppoing into my IMAP Maildir perfectly.

All I need to do now is get a copy of the mail left in the queue.

Is that JUST the ":0 c" recipe that I need Andrzej ?

jON

Andrzej Adam Filip

unread,
Apr 6, 2008, 7:23:04 PM4/6/08
to
sadsjon <jon.r...@sads.com> wrote:

WITH* some added magic/hack.
You *can not* simply "resubmit" the messages because they would be
delivered to the procmail script again.

I have posted one suggestion already [custom second submit-2.cf]

Another is presented in "man procmail" (R line for sendmail filtering)
but it seems to be from pre sendmail-8.12 era => it requires some
improvements to be "smtp ready" (MSA->MTA transfer)

--
[pl>en: Andrew] Andrzej Adam Filip an...@xl.wp.pl
Open-Sendmail: http://open-sendmail.sourceforge.net/

Knowledge, sir, should be free to all!
-- Harry Mudd, "I, Mudd", stardate 4513.3

sadsjon

unread,
Apr 7, 2008, 8:43:22 AM4/7/08
to
I'm sorry Andrzej , you have just about managed to confuse me to a
standstill :-)

>
> WITH* some added magic/hack.
> You *can not* simply "resubmit" the messages because they would be
> delivered to the procmail script again.

I guessed that I would not be able to resubmit but I thought your
original response to my mail suggested ways to delivery to multiple
systems. Does this mean that I can only deliver to multiple IMAP/mbox/
mail folders .... I thought you were saying that I would be to deliver
a copy to a mailbox whilst leaving the original in the queue.

>
> I have posted one suggestion already [custom second submit-2.cf]

Sorry, I don't understand this bit .. can you pint me to where this is
pls?

> Another is presented in "man procmail" (R line for sendmail filtering)
> but it seems to be from pre sendmail-8.12 era => it requires some
> improvements to be "smtp ready" (MSA->MTA transfer)

and I can't find any reference in "man procmail" that seems to be
relevant - is it perhaps version dependant?

With your proposed solution, I presume that the mail is taken out of
sendmail's hands .. yes?

I am not sure its a good idea to deliver the message to a mailbox - I
reckon its best to sneak a peek. Is there no way to achieve this?

many thanks, and sorry for my confusion.

jON

Grant Taylor

unread,
Apr 7, 2008, 11:05:58 AM4/7/08
to
On 04/05/08 07:58, sadsjon wrote:
> According to the docs, I need to add a "\" after the mailbox name to
> trigger a Maildir delivery but it doesn't seem to work if i add that
> to my RC script, it says user doesn't exist ...???

I think you mean a forward slash "/", not a back slash.

> Do you have any idea on the above Andrzej?

Are you sure that your Procmail is compiled to support Maildirs? I had
to make the following changes to my Procmail source code per their
documentation.

Maildir Support:
----------------
src/authenticate.c: uncomment line 50
from "/*#define MAILSPOOLHOME..."
to "#define MAILSPOOLHOME..."
src/authenticate.c: change line 50
from "/.mail"
to "/.maildir/"

Grant. . . .

sadsjon

unread,
Apr 7, 2008, 11:50:01 AM4/7/08
to

> I think you mean a forward slash "/", not a back slash.

Indeed I did Grant ... thats what you get for using Windows and Linux
at the same time :-)

> Are you sure that your Procmail is compiled to support Maildirs?  I had
> to make the following changes to my Procmail source code per their
> documentation.

Yes,my version (straight from the standard Debian build) worked
perfectly when once I had installed a default /etc/procmailrcs with
the following in :

DEFAULT=$HOME/Maildir/

jON

sadsjon

unread,
Apr 7, 2008, 12:59:44 PM4/7/08
to

Yes, I realised my error ... it was a type Kees.

cheers,

jON

Andrzej Adam Filip

unread,
Apr 7, 2008, 3:24:18 PM4/7/08
to
sadsjon <jon.r...@sads.com> wrote:

> I'm sorry Andrzej , you have just about managed to confuse me to a
> standstill :-)
>
>>
>> WITH* some added magic/hack.
>> You *can not* simply "resubmit" the messages because they would be
>> delivered to the procmail script again.
>
> I guessed that I would not be able to resubmit but I thought your
> original response to my mail suggested ways to delivery to multiple
> systems. Does this mean that I can only deliver to multiple IMAP/mbox/
> mail folders .... I thought you were saying that I would be to deliver
> a copy to a mailbox whilst leaving the original in the queue.
>
>>
>> I have posted one suggestion already [custom second submit-2.cf]
>
> Sorry, I don't understand this bit .. can you pint me to where this is
> pls?

submit.cf is a second *.cf file introduced in sendmail-8.12.
It relays locally submitted mail to 127.0.0.1:25.
[ it has been added to avoid set root installation ]

Making a copy of it relaying to another host and using another queue
directory required changing one line and adding another.

>> Another is presented in "man procmail" (R line for sendmail filtering)
>> but it seems to be from pre sendmail-8.12 era => it requires some
>> improvements to be "smtp ready" (MSA->MTA transfer)
>
> and I can't find any reference in "man procmail" that seems to be
> relevant - is it perhaps version dependant?

<quote src="man procmail">
This enables you to use rules like the following (most likely in
ruleset 0) to filter mail through the procmail mailer (please note
the leading tab to continue the rule, and the tab to separate the
comments):
R$*<@some.where>$*
$#procmail $@/etc/procmailrcs/some.rc $:$1...@some.where.procmail$2
R$*<@$*.procmail>$*
$1<@$2>$3 Already filtered, map back
</quote>

> With your proposed solution, I presume that the mail is taken out of
> sendmail's hands .. yes?
>
> I am not sure its a good idea to deliver the message to a mailbox - I
> reckon its best to sneak a peek. Is there no way to achieve this?

For peak (Bcc: with preserved envelope recipients) use milter
e.g. try (free) MIMEDefang milter based on perl script.

--
[pl>en: Andrew] Andrzej Adam Filip an...@xl.wp.pl
Open-Sendmail: http://open-sendmail.sourceforge.net/

Moneyliness is next to Godliness.
-- Andries van Dam

0 new messages