#!/usr/bin/perl -w # # Welcome to emailblog.pl # The intent of this script is to pass an email into the script. # like this: # emailblog.pl < mbox.email # or via procmail: # :0 # * ^(To|Cc|Resent-To).*someaddress@my\.com # | emailblog.pl # There's no license with this, its totally free. All I ask is that you notify me of any # changes you make to the script so that I can learn from what you did, and improve this # version of the script. emailblog at adhamh . com # This script shouldn't hose your machine, but if it does please don't ask me for help. :-) # The idea for this script was to create something that would allow me to blog by email # and support creating thumbnails of any jpg's attached to the email. # Its only be tested with http://blosxom.com! # TODO (for now): # Refactor code a bit and make it a little clearer as to the process being followed # Add more comments to the code # Add support for more image types, anything that ImageMagick can use will work # This script requires the Data::Dumper, MIME::Explode, and FileHandle # perl modules. It also requires ImageMagick be installed, this is easily # done using fink if running OS X. use Data::Dumper; use MIME::Explode; use FileHandle; use strict; # The script first parses the email message and determines what do to # The subject of the email defines what actions should be taken. # Example: # Subject: NewBlog EmailBlog # Would create a new blog entry under the category EmailBlog # Something like: # Subject: NewBlog EmailBlog/Test/Foo/Bar # should work too. # The idea is to allow for other commands to be added later # umask must be set if calling this script from procmail umask(0002); # your webserver url my $httpPath = "http://your.com"; # your webserver's document root my $webRoot = "/Library/WebServer/Documents"; # the path you use to view your blog my $blogName = "/yourblog"; # the directory inside your webRoot where blosxom docs are store my $blosxomdir = "/Blosxom"; # directory where temp files are stored my $tempDir = "/tmp"; # array for storing path to attachments my @attachments; # subject parsed from email my $subject = "nothing"; #parts of subject my @splitSubject; # used for naming log files if debugging is on. my $currentDate = "/".`date "+%B"`; my $thumbName; # This is the directory where you want to store you full size # images, its under the $webRoot direcotry my $pictureDirectory = "/images"; my $imageRoot = $webRoot . $pictureDirectory; my $blosxomRoot = $webRoot . $blosxomdir; # timestamp for uniquely nameing files in your blog directory. my $ctime = time(); # file name for you email's body (don't change) my $filename = $ctime; # category name for your blog (don't change) my $category = "none"; # command from subject (don't change) my $blogCommand = "none"; # this is the path where the script can find your convert utility # that was installed with ImageMagick my $pathToConvert = "/sw/bin/convert"; # set $debug to 1 for debugging output. # debug logs are written to /tmp/log.