|Send email using perl and sendmail|
on Nov 20, 2007 at 01:23 UTC
|Send email using perl and sendmail
|SSL mail with auth|
on Jul 26, 2007 at 14:32 UTC
|My isp just upgraded it's mail security to use ssl for both pop and smtp. Here are 2 scripts to connect to the pop-ssl and smtp-ssl-auth.
on Jan 10, 2007 at 19:41 UTC
|Just another quick and dirty script I used to extract e-mail addresses from an mbox mail file. It pulls them and prints them to the screen, so I redirect them to a text file and use the other, related script I posted emailverify.pl, to make sure they are valid.|
Again, not the prettiest script, but it got the job done!
|Email using sendmail|
on Sep 12, 2006 at 08:05 UTC
|hi monks |
i wrote small script to send mail from my unix box.
|CBE - Controle by E-mail vr 1.1|
on Mar 20, 2006 at 05:04 UTC
|You can send command via e-mail from mobile phone and script will do it =] You have to write in subject or status: =command= and send:)You have to have module Net::POP3|
|Mirror/Copy Mozilla thunderbird emails to IMAP server|
on Mar 08, 2006 at 09:40 UTC
This script works on Mozilla Thunderbird email stores, and attempts to upload the emails to an IMAP server. Right now, it's not finished, in that it doesn't upload the top-level emails (ie mails from Inbox, Sent etc). It handles subfolders of those just fine.
There's slso some dirty hackery to munge folder paths for dovecot. YMMV
Update: Fixed now, ie it correctly parses email in top-level folders. I'd still call it a quick-and-dirty script though.
|POP3 client - end|
on Dec 04, 2005 at 15:39 UTC
|I wrote (for me) nice script I use it always when i want to check mail.... i hope that somebody use this script and write me about it. Maybe you see some bad moves, or something.... tha n write in reply... I have to learn perl always and everywhere. Please comment this source|
|Get number of items in email account via POP3|
on Dec 03, 2005 at 13:17 UTC
|by Anonymous Monk|
|First of all, I have to confess that I am a newbie, and this is one of my first script in perl.And also I must tell that my english isn't very good, so I hope that you will be nderstanding.
What does it do?
When we put information about login, pass and pop3 server(in source) and than run script we will see today's date and how many post we have in own account e-mail.|
|Remove messages w/ duplicate bodies from mbox(es)|
on Nov 17, 2005 at 14:19 UTC
I found at least two ways -- procmail(1) and mutt(1) -- which can delete duplicate messages based on the Message-ID header. Failed i to find anything which would delete messages based on
Given mbox-format mailboxes, this program prints, on standard out, only those messages which are unique based on only the body. Original mailbox is accessed only for reading. Only the first
encountered instance (of multiplicates) is retained.
Update|Nov 17 2005: Updated pod.
on Aug 25, 2005 at 17:48 UTC
|Client/Server tool to send mails to many users that you have in a database. It reads a template file and will display a tree of objects in a Tk client you can build you mail on the fly based on the template. Then you choose the users you want to send it to, and send the MIME to the TkMailer server which in turns injects them into the QMail queue.
Even if you don't use Qmail, this program has a bunch of tricks and reusable code that you may need to build stuff like this. Things like Tk tricks, simple locale, sql tricks, MIME, templates, recursive functions, socket communication and many more. The code is very well documented for begginers and the code is not obfuscated, in fact it is perhaps too clear for many here. I built it for a client so they could maintain it themselves, so everything is very ordered, simple and clear. Great learning tool I guess.
If you would like to take this application further, be my guest but please drop me a line to see where it ends up, and of course, respect my choice of license.
|Light weight timesheet mailer|
on Aug 16, 2005 at 23:33 UTC
Light weight Tk and MIME::Lite based email program designed initially for sending daily time sheets that vary little from day to day.
Uses TK:form to lay out controls and manage resizing when the main window is resized.
on Jul 05, 2005 at 00:39 UTC
|I used to have exim on my server and it did some fancy forwarding so copies of firstname.lastname@example.org were forwaded to my pager. I switched to postfix (and love it), but postfix doesn't do fancy forward filtering, and who wants bloated procmail, so I made a little perl script that does the trick.
just put this in your .forward:
Postfix will pass the email to the script and away you go.
This is the first in my continuing series of "poorly commented, slapped together scripts from rob"
Next I want to see how to redirect any errors generated by this script. Right now they are emailed to the sender of the emailt hat triggered the script - not too helpful.
live long and prosper
|flexible command line mail sender (SMTP)|
on Jun 23, 2005 at 07:44 UTC
|A Simple tool to send mails from the command line via a smptp server.|
|Check IMAP Folders for new messages|
on Apr 21, 2005 at 12:56 UTC
|This script displays the number of new, and total messages, in each folder of an IMAP account.
It currently has the following limitations:-
- The folder separator is hard-coded with split()
- Not as fast as it could be, as I could find no way to fetch just the new message count for a folder (with Net::IMAP::Simple). Instead it checks the status of each and every message.
- Currently no support for SSL
|Send email with attachment(s)|
on Jan 18, 2005 at 09:49 UTC
|This code demonstrates how to use MIME::Entity and MIME::Types to add attachment(s) to an outgoing email.|
|attachments — mass-dumps file attachments from mail|
on Nov 02, 2004 at 21:21 UTC
Does what it says on the tin. Reads from standard input or files/folders, so it is easy to use from your .procmailrc, from within your MUA, or the shell.
This was a joy to write – I have to thank to Simon Cozens and his cohorts for a bunch of great email modules.
Also, a practical application of Batch processing progress printer.
|Exchange to Squirrelmail Global Address Book|
on Sep 01, 2004 at 15:17 UTC
We replaced Outlook Web Access with Squirrelmail. To make use of Squirrelmail's global address book option, we could have done LDAP lookups or put this in a local MySQL database. But, just a plain old boring text list was equally useful.
Adjust the $ldapsrv variable, change the "yourdomain.com" in "(mail=*yourdomain.com) to reflect your local mail domain, pipe it to global.abook and scp it to your system running Squirrelmail (On Debian Woody, it's in /var/lib/squirrelmail/data).
The only caveats are that:
- We just dupe the full name for the name and nickname categories. Our users get confused by the nicknames, so this makes it easier for them. It includes all distribution lists as well.
- We split the "cn" returned at the first white space. The abook wants a first and last name, but DLs have more than two words. So, The first word becomes the given name and the rest becomes the surname.
|Map Perdition IMAP proxy to mailboxes on multiple Exchange servers|
on Aug 30, 2004 at 16:22 UTC
We replaced Outlook Web Access with Squirrelmail/Perdition running on Debian Linux. The problem is that, with 1,000 users who are unknowing of which mail server holds their mailbox, we decided on an IMAP proxy to Exchange (Perdition).
This script generates Perdition's popmap config file from a dump of the Exchange directory and restarts Perdition. Details on generating the directory dump are here: http://www.unixwiz.net/techtips/postfix-exchange-users.html. I'd love to hear of someone found the HOME_SERVER variable via LDAP lookups to Exchange. It might be right in front of me, but I don't see it. I don't cover the Squirrelmail or Perdition configs, either.
Here's my version of the two config files and one batch file mentioned at the above link for this script:
Important note: use the netbios name of the Exchange server. It always fails for me if I use a FQDN.
; 09 = TAB
; 37 = %
; 34 = "
Obj-Class Alias Name Home-Server
copy exportfields.txt exchusers.txt
\exchsrvr\bin\admin /e exchusers.txt /n /o userexport.ini
|Legitimail.pl - Make Postfix relay recipient tables from Exchange smtp addresses|
on Aug 30, 2004 at 14:48 UTC
We use this to run an ldap query from our external OpenBSD/Postfix MTAs to an Exchange 5.5 server so we can generate a Postfix relay recipient map of legitimate mailboxes (witty, eh?). We reject non-legit mail at the external MTA level.
YMMV... blah blah blah. We run it twice a day from cron and scp the results to the public-facing MTAs. It's only 1,000 or so addresses, so the run time and copy time are pretty short.
Also, we don't accept smtp deliveries to distribution lists. So, only directory entries of the type "organizationalperson" are grabbed. DLs would require "groupofnames" entries to be returned as well.
Updated 2004-09-02: I changed from the ldapsearch binary to Net::LDAP.
|IMAP bodystructure parser|
on Jul 06, 2004 at 17:40 UTC
|This module parses a BODYSTRUCTURE part of fetch response from an IMAP server. This is my first module that could be of any use to someone although I am a perl programmer for 4 years now. I intend to release it to CPAN so I would really appreciate a review.|
|Gmailize your IMAP (and more)|
on Jul 02, 2004 at 04:20 UTC
|Take your IMAP messages and archive them to your gmail account.|
|Automatic e-mail whitelist creator|
on May 26, 2004 at 22:43 UTC
Creates a white-list of people that are allowed to send you e-mail because they are in your inbox or you have already talked to them via e-mail. This program culls your address book, sent mail and anything else you give to it for e-mail addresses.
Alter your procmailrc to filter for viruses, the whitelist and then your spam folder.
on Apr 05, 2004 at 00:11 UTC
|This module allows you to access your web-based Yahoo Mail account
programatically. Similar in function to Mail::Webmail::Yahoo, this
module is more geared towards manipulation of individual messages,
rather than simple bulk download.|
|GPG Key prefetcher|
on Jan 03, 2004 at 11:56 UTC
|This wad of code reads text on stdin, thought to contain references to public keys, in the form of URLs, hex numbers (0xdecaf), and optionally emails (i can't test them).
PGP::FindKey was broken for my keyservers, and I can't install Crypt::OpenPGP::KeyServer, so emails are only theoretically available.
The code outputs key blocks on STDOUT.
wrap it in something like
or if you don't want to suffer the delay, have it slurp it's input, daemonise (as per perlipc), and pipe to gpg itself.
|gpg-key-downloader | gpg --import
Updates: removed a proxy env set, and detabbed, formatting, description (sorry, I thought i hit a preview button), added comments
|Simple virus checker...|
on Nov 11, 2003 at 13:52 UTC
|Maybe you have a slight desire to know just what all those huge executables arriving in your inbox are infected with. This script uses File::Scan and MIME::Parser to tell you ... I invoke it from mutt by pressing 'i', with the following line in .muttrc: 'macro index i "|vscan"'|
|mx - Mail Exchanger (MX) information about internet hosts|
on Oct 08, 2003 at 17:15 UTC
|A tool to find out far more than you ever wanted to know about MX records. In case you didn't know, MX records are a certain type of record used to discover which host will accept SMTP mail for a given domain.|
|Kill that Swen worm on your POP3 account!|
on Sep 21, 2003 at 13:12 UTC
|Currently my mailbox is just flooded with the newest e-mail worm, Swem. I receive about 50 of them an hour, at 150k each. So I wrote a script to check my POP3 account, for each mail fetch the headers and the first lines, and see if it's most likely a worm mail, by checking if it appears to contain an executable as an attachment. If so, it deletes it. There's no specific test for this particular worm.
You can run it both at home, where you save bandwidth, by avoiding to download the entire message, and your precious time, of course; or, as I do, put them on a server somewhere on internet, and run it from there. I put it in my crontab, and let it run ever 20 minutes, like this:
Note that this server is a different server than the one my mail arrives at.
14,34,54 * * * * $HOME/mailwormkiller.pl >>$HOME/mailwormkiller.lo
The display in the log (via STDOUT) shows a table of all mails that arrived, with mail number, what type of executable it found (if any) and at what line number, sender, and subject. The line number is in order to tweak the initial number of lines fetched for the body. I found that the offending content-type line, for this worm, usually appears earlier than line 20, or around line 300.
Update (Sep 28, 2003 14:00 CEST — extra update at 15:37 CEST):
Edited the regexp to trap more other worms:
- Allow for wrapped Content* headers
- Match filenames both in Content-Type and in Content-Disposition headers
Update (Nov 30, 2004 16:10 CET):
Added the "cpl" extension (control panel)
|popcheck - Simple POP3 mail checker|
on Aug 10, 2003 at 02:55 UTC
|Well, mutt died on me (ncurses upgrade) and I was waiting for a really important e-mail ...So I wrote this up in 10 minutes, and got me that e-mail. :-)
Thought it might help someone else, or even teach them (in a simplific style) how to use Net::POP3 .|
|Spam bounces catcher|
on May 12, 2003 at 09:45 UTC
|I've been having trouble with spammers using my domain + a random username to send spam from. Dealing with the bounces was annoying - I'd need to check each one to see if it was genuine.|
The following code looks for bounces, changes the subject to Bounced: email@example.com, where the email address is where the email was bounced to, and adds a header I can use to send it to an appropriate place with procmail. For example:
May 12 System Administ ( 153) Bounced: firstname.lastname@example.org
on May 01, 2003 at 08:59 UTC
|Moves spam from one Maildir to another, removing flags. Hardcoded everything, so change it before using it :)|
Usage: perl mvspam.pl Maildir/cur/*
on Apr 05, 2003 at 14:26 UTC
|by Mr. Muskrat|
|Send an email to a Metrocall My2Way pager using their messaging gateway. See Metrocall My2Way for more details.|
on Dec 03, 2002 at 00:57 UTC
|A little script that i made to send an e-mail to all users in /etc/passwd, i made this to learn more about perl and Mail::Sendmail module|
|Web page digest mailer|
on Nov 11, 2002 at 14:54 UTC
|This script was originally designed as a quick hack for use by the Gene Ontology (www.geneontology.org) project. It scans a web page for the designated table, strips out old entries, and mails any new entries. The script is designed to be run as often as you would like, but only to mail results after $cacheperiod seconds following the previous mailing. In this way the script can capture short-lived entries without overwhelming the end user(s) with mail.|
The code is still set up to scan the Gene Ontology SourceForge web page, as an example.
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=<email@example.com>, relay=[200.XXX.XXX.XXX], reject
+=550 5.7.1 <firstname.lastname@example.org>... Relaying denied
Tue Nov 27 21:08:39 2001 budapest sendmail: fARA8Gh02679: rulese
+t=check_rcpt, arg1=<email@example.com>, relay=[200.XXX.XXX.XXX], re
+ject=550 5.7.1 <firstname.lastname@example.org>... 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