root/misc/randmail.pl

Revision 1084, 1.2 kB (checked in by alpt, 1 year ago)

bla bla

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1 #!/usr/bin/perl
2 #
3 # randmail.pl:
4 # it will send a random mail on a random date to a random person.
5 # You must have `at' installed.
6 #
7 # Fri Mar 24 11:54:44 CET 2006
8 # -  AlpT (@freaknet.org)
9 #
10 # thanks to Arfalas, you're my Muse ;*
11
12 # Configure this filename. In it you shall put a plain list of email addresses
13 # (one per line) or a list of alias in the mutt style
14 # (i.e. "alias foo bar <foobar@barfoo.foo>"
15 $ALIAS_FILE="~/.mail_aliases";
16 $signature=`cat ~/.signature`; #Your signature
17
18 $iam=`whoami`;
19 $date=`date +"%H:%M:%S %d/%B/%Y"`;
20 $iam  =~ s/\n$//;
21 $date =~ s/\n$//;
22 $time = int(rand(43200))%43200+24;
23
24 ##
25 ### Write your message here
26 ##
27 $SUBJECT = "Yo! I am $iam. Bla bla... ";
28 $MSG= <<MSG_BODY;
29 I am $iam,
30
31 this is a mail coming from the past,
32 it has been created at:
33 $date.
34 Exactly after $time hours ago.
35
36
37 bla bla bla
38
39 Cya
40 --
41 $signature
42 MSG_BODY
43
44 $ALIAS_FILE=`echo $ALIAS_FILE`;
45 open(FH, "< $ALIAS_FILE") || do { print "Cannot open $ALIAS_FILE: $!"; exit 1 };
46 @mails = <FH>;
47 $w1 = $mails[int(rand($#mails))];
48 if ($w1=~/<(.*)>/) {
49         $w1=$1;
50 } else {
51         chomp $w1;
52 }
53
54 open(MAILFD, "> /tmp/rmail");
55 print MAILFD "cat <<MAIL_MESSAGE | mail -s \"$SUBJECT\" $w1\n$MSG";
56 $at_cmd=`cat /tmp/rmail | at now + $time hours`;
57 print $at_cmd;
58 close(MAILFD);
Note: See TracBrowser for help on using the browser.