on Sep 14, 2002 at 19:13 UTC
|Builds a hash whose index is a "from" "to" pair, and then increments it every time the pair is encountered. Finally, the information is sorted displaying the highest pairs first. Tested on HPUX 11.0 running Sendmail 8.9.3.|
|Parsing emails with attachments|
on Sep 05, 2002 at 16:54 UTC
This code demonstrates how to use mime::tools to parse an incomming email into 6 parts:
- Attachment names
- Actual attachment files
|Convert CSV export from Outlook - MySQL|
on Jun 24, 2002 at 22:36 UTC
|No rocket science - only posted here to save you quarter of an hour, and because it's the solution to a SOPW I posted. Does what it says on the can. Use the File Export utility in Outlook to create DOS CSV files from all your email folders. Put all these CSV files (I cut off the file extension - you may find you need to do this) in an otherwise empty directory. Change "db" below to the name of your directory. Create a MySQL table with the columns listed in @cols below, plus an extra auto-increment column "ID". (I made all the below cols TINYTEXTs except for Body which was LONGTEXT - database experts will use more optimal definitions.) NB you may also find, if you are executing the script on a different machine from that on which the CSV files were originally written (and if one's *NIX and the other M$) that DBI doesn't read your CSV files without you artificially put in MS linebreaks between records - this took me some hair-tearing to figure out.|
(At the risk of being --ed by my fellow zealots, I should acknowledge that I ran this without warnings because with warnings, although it does what I wanted it to do, it raises the following:
... which I am at a loss to understand.)
Argument "" isn't numeric in scalar assignment at /usr/lib/perl5/site_
+perl/5.6.1/DBD/CSV.pm line 197
|Sending HTML Mail|
on May 08, 2002 at 19:15 UTC
|The marketing department sends HTML newsletters to customers and investors. They are currently using a desktop email client (sounds like outhouse) that gives inconsistant results.
This script simpifies things:
|forking/envleloping/Mulipart Mime Newsletter Mailer|
on May 06, 2002 at 10:44 UTC
|This is for large outbound newsletters.
Uses Mail::Bulkmail and Mime::Lite to send out multipart mime encoded enveloped messages. This takes it a step further in that it will send out using specified mail servers to optimize the speed at wich you can send. currently using 2 SMTP servers to and a list management server to send I get 70-75msgs/sec thats 270,000/hr and ~4milion every 15 hours (if i had that much mail to send)
goto http://www.f00bar.com/files/send.pl.html for latest version
Fixed a bug whith the date in the headders.. also stupid bug with the DEBUG sub..
<NOTE> I do not use this to spam anyone I know it could be used for those purposes. It is a piece of code i am actually kind of proud of although I know it could be improved. </NOTE>
|Valid Email Filter|
on Mar 25, 2002 at 14:10 UTC
|The marketing department wants to send emails to people who sign up on the company website. But who actually gives their real address? You try to explain this to them but, you're outranked. At least save yourself many of the annoying bounces and deferred messages that can clog your mail queue.
This script will check a list of email address (one per line) and see if they are valid by RFC compliance and by performing an MX DNS query.
This scirpt is NOT perfect. No email validation script can be. For most purposes it will suffice.|
|Store Lotus Notes Email|
on Jan 05, 2002 at 01:10 UTC
|This Win32 program extracts all email messages from your Lotus Notes account, and saves the text and all of the attachments to your hard drive.
Some of this code was based on the excellent program getnotes.pl
|Palm::Addressbook to Sylpheed addressbook converter|
on Dec 01, 2001 at 23:03 UTC
|This code converts a Palms Addressbook to Sylpheeds addressbook. It uses XML::Writer, Palm::Addressbook (and parent modules). Sylpheed is a GTK+ based, lightweight, and fast e-mail client.|
See comments for more info.
|Attempted mail relay reporting|
on Nov 27, 2001 at 18:52 UTC
|In attempting to track down and report a number of attempted mail relays through some of my mail servers, I decided to employ Perl to perform a bit of log analysis for me. The result was the following code which parses through the server sendmail log, identifying questionable ruleset checks, extracts the originating relay host and performs a network lookup on the host. This information, with the relevant log extracts, is then reported via email to a predefined email address for further action.|
An edited example of the email output follows:
Please note that this code does not directly contact the administrator of the network from which the mail relay was attempted, a discretionary exercise left for the mail server administrator.
Example Inc. (NET-EXAMPLE-BAD) EXAMPLE-BAD
200.XXX.XXX.XXX - 200.XXX.XXX.XXX
Results brought to you by the GeekTools WHOIS Proxy
Server results may be copyrighted and are used with permission.
Tue Nov 27 21:08:39 2001 budapest sendmail: fARA8Gh02679: rulese
+t=check_rcpt, arg1=<firstname.lastname@example.org>, relay=[200.XXX.XXX.XXX], reject
+=550 5.7.1 <email@example.com>... Relaying denied
Tue Nov 27 21:08:39 2001 budapest sendmail: fARA8Gh02679: rulese
+t=check_rcpt, arg1=<firstname.lastname@example.org>, relay=[200.XXX.XXX.XXX], re
+ject=550 5.7.1 <email@example.com>... Relaying denied
on Sep 05, 2001 at 19:46 UTC
|Net::SMTP_auth is a small extension to G. Barr's Net::SMTP to authenticate to an SMTP server using one of the AUTH methods PLAIN, LOGIN or CRAM-MD5 (see RFC2554 for details). This module can be expanded and is a very first implementation. (Updated, yes there was a typo)|
on Aug 08, 2001 at 23:50 UTC
pemail is a Perl project I am working on to better learn the Perl language, and to develop my coding skills in general. I don't expect others to find much use out of it, as there are already tools that do its jobs much better, but this is mostly for my own benefit.
pemail allows you to view POP3 email from the command line, with a fairly intuitive interface, much like the UNIX mail(1) command does. pemail also allows you to send email from the same interface, making it pretty much an all in one mail client for the UNIX command line.
pemail requires the Mail::POP3Client and MIME::Lite Perl modules to work.
reading email: pemail -P <server> [-u <username> [-p <password>]]
sending email: pemail -s [address]
Just fill out the information requested and pemail will check your POP3 mailbox, tell you how many messages you have, and then you can do what you like with them.
- Hmm... a good thing to try putting in would be forwarding
and replying to emails...
I'm putting this code up here for suggestions on features to add and any possible bugs to fix... unfortunatley pemail as a project has stagnated and I haven't done any work on it since Dec. 19, 2000.
More info on pemail can be had at http://www.the-den.org/pemail (when the cable modem is working correctly... sigh). Also of note is that this program was listed in Linux Journal's "Focus on Software" column sometime in late 2000 (don't have the issue handy for an exact month).
on Apr 20, 2001 at 03:02 UTC
|A utility which combined with a procmail filter will
ditch spam for you using the Realtime Blackhole List
or any compatible service.|
This code provides a nice example of how to do simultaneous
lookups with Net::DNS.
Note that there is a CPAN module to do part of this Mail::RBL but
it doesn't parse mail messages for you and it doesn't do multiple IP
See the start of the code for some more details and a procmail
Note that you need to be online when this program is running
which you probably will be if you use fetchmail or sendmail directly.
|LDAP address lookup from Mutt|
on Mar 17, 2001 at 20:45 UTC
Mutt allows you to add a hook for an external address
lookup program. A common one is LDAP, and this simple
script does the lookup for you. Once this is setup, you
can enter part of a person's first or last name, hit
^T and the LDAP search will be performed.
Just add the following line to your
.muttrc, changing the name of
the script to whatever you save it as:
set query_command = "~/bin/mutt_ldap.pl '%s'"
You'll have to set the proper information for the constants
HOST and BASE and, if your
LDAP server doesn't allow anonymous binds, also pass
the full DN mapping to your user record and password
to the bind() method. Also, if you
have a nonstandard schema you'll have to modify the
LDAP property names.
on Feb 09, 2001 at 11:34 UTC
|Rotate those tired .signature taglines automatically. Put your taglines in the file $siginfile, one tagline per line. Setup a cron job to run the script every few minutes. Now you won't have to manually change your .signature line.
Output looks something like this:
Backup not found! A)bort, R)etry or P)anic?
10:25pm up 23:22, 6 users, load average: 1.04, 1.10, 1.14
|Strip Brain-Damaged Mails of "HTML Alternative" Evilness|
on Jan 22, 2001 at 06:55 UTC
|Durn it if there seems to be no way for Outlook with Win2K to turn off that evil "HTML version" of mail. A MIME is a terrible thing to waste, so let's strip that as it comes in. Set up a procmail recipe to pipe mail that has both boundary and html in its content-type header through this program, and you'll never have to deal with that evil embrace-and-extend garbage from Redmond again.
It's safe to pipe all mail through this, if you don't want to be clever with procmail. You also might want to do something sensible with the die there. I put the hook there just in case, although all I'm doing is re-throwing it.
See also the column I wrote around this program.
|Simple POP 3 Client Ver 1.0|
on Mar 12, 2001 at 10:22 UTC
|This program connects to POP3 server and checks the mail sitting in the mail box. Then each message header and body can be parsed as per the requirement.|
on Jul 04, 2000 at 17:25 UTC
|by Shotgun Bob|
This perl script checks your e-mail account with the
flags that you provide at the command line.
NOTE: This perl script requires the Net::POP3 module.
Get it from:
pop_check <server_name> <account> <password>
on May 05, 2000 at 12:16 UTC
|This is basicly a form-to-email script that uses format declarations as "templates" to format the output to mail.|
on May 01, 2000 at 01:43 UTC
|This is a Lotus Notes client written in perl.|
on Jan 28, 2000 at 01:14 UTC
An old script I wrote about a year ago.
Not very elegant but gets the job done.
Sending out seemingly personalized letters to a list of people.
It takes a couple of files:
A data file that looks like:
It needs an EMAIL column so it knows where to send the mail to
the rest of the columns are up to you. Column headers and row
data are separated by |'s
Then you just make a message file like so and it makes the
Your e-mail address is: EMAIL