procmail
[Top] [All Lists]

Re: Send emails at certain time all together

2001-04-17 02:59:48
* Daisuke Miyagawa <mail(_at_)31(_dot_)com> [010410 17:15]:
I want to send emails to cell-phones at night but 
if i email  at night, recipients are awaked.

So what i want to do is... 

STEP 1. I send some emails at night. 
 (But its "To" add. is not real recipients' add. but dummy address at my 
domain, 
like send_at_noon(_at_)31(_dot_)com(_dot_)
And I keep recipients' add. somewhere in the emails)

STEP 2. emails to send_at_noon(_at_)31(_dot_)com are stored but sent to no 
one.

STEP 3. At noon of the next day,
 emails are sent to real recipients, with recipients' add. at To:.

(I can use crontab at my domain.)

Perhaps I can solve this with procmail and crontab, but
I am newbie about procmail, so i have not idea what to do at STEP3.

will you give me any hints or examples that realize such situations?

Here's an idea and a couple of files for illustration.  Untested, of
course.  Use at your own risk.  

I'm thinking you should have a a directory called 'emails' in your
$MAILDIR.  You should also add a 'To:' header to the body of your
emails for the following script to work.

For example, if you wanted to send a message to bob at noon the next
day, you would write this in your cellphone.

"
To: bob(_at_)31(_dot_)com
Hey bob.  This gets sent out at noon. :))
"

Here're the files.

.procmailrc:
:0:
* ^TO_send_at_noon(_at_)31\(_dot_)com
emails

crontab:
0 12 * * *  /bin/bash /path/to/send_emails.sh

send_emails.sh:
#!/bin/sh

cd /patch/to/procmail/emails
for email in *
do
    # extract the Subject from the header
    SUBJ=`cat $email | formail -xSubject: | sed 's/^Subject: //'`
    
    # extract your To: header from the _body_
    TO=`cat $email | sed '1,/^$/d' | grep To: | sed 's/^To: //'`

    # send off the email
    mail -s "$SUBJ" $TO

    # if all went well, rid yourself of the email
    if [ $? = 0 ]; then
        rm -f $email
    fi
done

-- 
From my great-grandfather, not to have frequented public schools,
and to have had good teachers at home, and to know that on such things
a man should spend liberally.
   -- Marcus Aurelius, the Mediations, book 1
--
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>