email builder | 27 Oct 2011 00:24
Picon
Favicon

Send separate notification to $LOGNAME during maildrop execution

Hello,

I want to send a notification to the recipient ($LOGNAME) under certain conditions.  This is in addition
to normal message delivery.

A couple issues arise:

1) This creates a mail loop.  To prevent this, we currently create a file in the home directory whose
presence indicates that the notification was sent and doesn't need to be re-sent.  This works fine, but
I'd like to know if there is a better way to handle this.

2) What's the best way to create and send a separate email inside of maildrop?  We considered mailbot,
which has options we could use to override the recipient address, but using an autoresponse tool for this
seems inappropriate.  Currently, we have a slightly awkward sendmail execution:

/^Delivered-To:\s+.*? <at> (.*)/:h
DOMAIN="$MATCH1"
cc "| (echo 'Subject: Hello World'; echo 'X-Priority: 1 (Highest)'; echo 'To: $LOGNAME'; echo ''; echo
'This is the notification email body.'; echo 'Each line of the body is in a separate echo statement.';) |
$SENDMAIL -t -F Postmaster -f postmaster <at> $DOMAIN -r postmaster <at> $DOMAIN $LOGNAME"

3) As you can see above, we are trying to determine the domain dynamically.  Is parsing the Delivered-To
header reliable?  Is there a preferred way to handle that?

------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning <at> Cisco Self-Assessment and learn 
about Cisco certifications, training, and career opportunities. 
http://p.sf.net/sfu/cisco-dev2dev
(Continue reading)

Sam Varshavchik | 27 Oct 2011 02:58
Gravatar

Re: Send separate notification to $LOGNAME during maildrop execution

email builder writes:

> Hello,
>
> I want to send a notification to the recipient ($LOGNAME) under certain  
> conditions.  This is in addition to normal message delivery.
>
> A couple issues arise:
>
> 1) This creates a mail loop.  To prevent this, we currently create a file in  
> the home directory whose presence indicates that the notification was sent  
> and doesn't need to be re-sent.  This works fine, but I'd like to know if  
> there is a better way to handle this.

Add a custom header to the notification mail. That tells you it's a  
notification mail.

But why even send the mail in the first place, when you have the mailbox  
right there. Just assemble your message, and deliver it directly to the  
mailbox.

>
> 2) What's the best way to create and send a separate email inside of  
> maildrop?  We considered mailbot, which has options we could use to override  
> the recipient address, but using an autoresponse tool for this seems  
> inappropriate.  Currently, we have a slightly awkward sendmail execution:
>
> /^Delivered-To:\s+.*? <at> (.*)/:h
> DOMAIN="$MATCH1"
> cc "| (echo 'Subject: Hello World'; echo 'X-Priority: 1 (Highest)'; echo  
(Continue reading)

email builder | 27 Oct 2011 04:27
Picon
Favicon

Re: Send separate notification to $LOGNAME during maildrop execution

>>  I want to send a notification to the recipient ($LOGNAME) under certain 

> conditions.  This is in addition to normal message delivery.
>> 
>>  A couple issues arise:
>> 
>>  1) This creates a mail loop.  To prevent this, we currently create a file 
> in the home directory whose presence indicates that the notification was sent 
> and doesn't need to be re-sent.  This works fine, but I'd like to know 
> if there is a better way to handle this.
> 
> Add a custom header to the notification mail. That tells you it's a 
> notification mail.
> 
> But why even send the mail in the first place, when you have the mailbox right 
> there. Just assemble your message, and deliver it directly to the mailbox.

Ah yes - hard to see the forest for the trees (vice versa?)!

But how do you deliver a secondary message to the maildir?  The to/cc commands only send the incoming
message as far as I can tell from the docs (and eventually we want that to happen, too, so we don't want to
lose/overwrite the original message).  It doesn't seem like a good idea to write out a filename to the
maildir in a format that's different from what Courier expects.  

Sorry, but can you provide a little more assistance on this?  

THANK YOU!!!!

------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
(Continue reading)

Sam Varshavchik | 27 Oct 2011 05:14
Gravatar

Re: Send separate notification to $LOGNAME during maildrop execution

email builder writes:

> >>  I want to send a notification to the recipient ($LOGNAME) under certain
>
> > conditions.  This is in addition to normal message delivery.
> >>
> >>  A couple issues arise:
> >>
> >>  1) This creates a mail loop.  To prevent this, we currently create a file
> > in the home directory whose presence indicates that the notification was  
> sent
> > and doesn't need to be re-sent.  This works fine, but I'd like to know
> > if there is a better way to handle this.
> >
> > Add a custom header to the notification mail. That tells you it's a
> > notification mail.
> >
> > But why even send the mail in the first place, when you have the mailbox  
> right
> > there. Just assemble your message, and deliver it directly to the mailbox.
>
> Ah yes - hard to see the forest for the trees (vice versa?)!
>
> But how do you deliver a secondary message to the maildir?  The to/cc  
> commands only send the incoming message as far as I can tell from the docs  
> (and eventually we want that to happen, too, so we don't want to  
> lose/overwrite the original message).  It doesn't seem like a good idea to  
> write out a filename to the maildir in a format that's different from what  
> Courier expects. 
>
(Continue reading)

email builder | 27 Oct 2011 07:46
Picon
Favicon

Re: Send separate notification to $LOGNAME during maildrop execution


>>  > But why even send the mail in the first place, when you have the 
>> > mailbox right
>>  > there. Just assemble your message, and deliver it directly to the 
>> > mailbox.
>> 
>>  Ah yes - hard to see the forest for the trees (vice versa?)!
>> 
>>  But how do you deliver a secondary message to the maildir?  The to/cc 
>> commands only send the incoming message as far as I can tell from the docs (and 
>> eventually we want that to happen, too, so we don't want to lose/overwrite 
>> the original message).  It doesn't seem like a good idea to write out a 
>> filename to the maildir in a format that's different from what Courier 
>> expects. 
>> 
>>  Sorry, but can you provide a little more assistance on this? 
> 
> You can use the cc command to run any external command that reads the existing 
> message on standard input. It's important to read and drain the original 
> message from standard input, so that maildrop considers the message being 
> delivered, and won't report an error. But then, your external command or a 
> script can construct its own message, and pipe it to deliverquota, to deliver it 
> to the maildir. Deliverquota is a cheap way to place a message into a maildir.

Thank you kindly, Sam.

------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning <at> Cisco Self-Assessment and learn 
(Continue reading)


Gmane