<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>HJK Solutions: Tag perl</title>
    <link>http://blog.hjksolutions.com/articles/tag/perl</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>We Launch Startups</description>
    <item>
      <title>Catalyst Deployment with Apache 2 and mod_fcgid</title>
      <description>&lt;p&gt;Catalyst has long had &lt;a href="http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7007/lib/Catalyst/Engine/FastCGI.pm"&gt;FastCGI support built in&lt;/a&gt;, but all of the recipes are for the much older &lt;a href="http://www.fastcgi.com/"&gt;mod_fastcgi&lt;/a&gt;.  As a Debian user, and fan of software that&amp;#8217;s still maintained, I prefer &lt;a href="http://fastcgi.coremail.cn/"&gt;mod_fcgid&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;What follows is a simple Apache 2 virtual host for a Catalyst application, using mod_fcgid:&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
&amp;lt;VirtualHost *:80&amp;gt;
    ServerName www.example.com
    ServerAlias example.com
    ErrorLog logs/www.example.com.error_log
    TransferLog logs/www.example.com.access_log

    # This should point at your myapp/root
    DocumentRoot /srv/myapp/root
    Alias /static /srv/myapp/root/static

    &amp;lt;Location /static&amp;gt;
        SetHandler default-handler
    &amp;lt;/Location&amp;gt;

    Alias / /srv/myapp/script/myapp_fastcgi.pl/

    &amp;lt;Location /&amp;gt;
        Options ExecCGI
        Order allow,deny
        Allow from all
        AddHandler fcgid-script .pl
    &amp;lt;/Location&amp;gt;
&amp;lt;/VirtualHost&amp;gt;
&lt;/code&gt;
&lt;/pre&gt;</description>
      <pubDate>Thu, 19 Jul 2007 14:38:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:1510e278-e069-4026-9f34-33a288ca5e0f</guid>
      <author>Adam Jacob</author>
      <link>http://blog.hjksolutions.com/articles/2007/07/19/catalyst-deployment-with-apache-2-and-mod_fcgid</link>
      <category>solutions</category>
      <category>perl</category>
      <category>catalyst</category>
      <category>apache</category>
      <trackback:ping>http://blog.hjksolutions.com/articles/trackback/4</trackback:ping>
    </item>
    <item>
      <title>Re-Queing a mailbox full of bounced messages</title>
      <description>We've recently run in to a situation where we had a fairly large number of legitimate messages bounce due to a misconfigured MTA. Once we fixed the MTA, we needed to get all of those messages back out the door again. It was a job for CPAN.
&lt;pre&gt;
    &lt;code&gt;

use strict;
use warnings;        
use Mail::Box::Manager;
use Email::MIME;
use Email::Send;

foreach my $mbox (@ARGV) {
    my $mgr = Mail::Box::Manager-&gt;new;
    my $folder = $mgr-&gt;open(folder =&gt; $mbox);
    my $sender = Email::Send-&gt;new({mailer =&gt; 'SMTP'});
    $sender-&gt;mailer_args([Host =&gt; 'localhost']);

    foreach my $msg ($folder-&gt;messages) {
        PART: foreach my $part ($msg-&gt;parts('ALL')) {  
            my $body =  $part-&gt;decoded;
            if ($body =~ /This is the mail system at/) {
                next PART;
            } elsif ($part-&gt;decoded =~ /Action: failed/) {
                next PART;
            } else {
                my $email = Email::MIME-&gt;new(\$part-&gt;decoded);
                print "Sending to: " . $email-&gt;header("To") . "\n";
                $sender-&gt;send($email);
            }
        }
    }
}
&lt;/code&gt;
&lt;/pre&gt;
The code uses a couple of different modules:
&lt;ol&gt;
&lt;li&gt;&lt;a href="http://search.cpan.org/~markov/Mail-Box-2.071/lib/Mail/Box/Manager.pod"&gt;Mail::Box::Manager&lt;/a&gt;: handles opening a mailbox (in pretty much every common format)
and extracting messages.
&lt;li&gt;&lt;a href="http://search.cpan.org/~rjbs/Email-MIME-1.859/lib/Email/MIME.pm"&gt; Email::MIME&lt;/a&gt;: lets you construct a new email from a MIME encoded message. 
&lt;li&gt; &lt;a href ="http://search.cpan.org/~rjbs/Email-Send-2.185/lib/Email/Send.pm"&gt;Email::Send&lt;/a&gt;: takes our Email::MIME object and sends it out (in this case, via SMTP, but you can choose your mechanism.)
&lt;/ol&gt;
So should you ever find yourself with a couple thousand erroneously bounced messages, don't fret. ;)

</description>
      <pubDate>Mon, 11 Jun 2007 20:04:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:68694964-e1b1-45a7-85fd-e3735f12c54c</guid>
      <author>Adam Jacob</author>
      <link>http://blog.hjksolutions.com/articles/2007/06/11/re-queing-a-mailbox-full-of-bounced-messages</link>
      <category>solutions</category>
      <category>perl</category>
      <category>email</category>
      <trackback:ping>http://blog.hjksolutions.com/articles/trackback/2</trackback:ping>
    </item>
  </channel>
</rss>
