davemabe has asked for the wisdom of the Perl Monks concerning the following question:

I have an application that spits out emails to a directory and stores them in BSMTP format like so:
HELO server.domain.com MAIL FROM:<dmabe@domain.com> RCPT TO:<user@gmail.com> DATA Return-Path: <dmabe@domain.com> Received: from nj580spare2.jetlab.domain.com (135.65.248.219:43594) by + nj530iis1.ugdtst.domain.com (LSMTP for Windows NT v1.1b) with SMTP i +d <0.0000000E@nj530iis1.ugdtst.domain.com>; Thu, 23 Sep 2004 8:53:27 +-0400 Subject: Testing - sending to user@gmail.com 2 Date: Thu, 23 Sep 2004 08:35:20 -0400 Message-ID: <30016CC3B435374EAB27C35892EEFAAC0206FA@nj580spare2.jetlab +.domain.com> X-MS-Has-Attach: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-MS-TNEF-Correlator: Thread-Topic: Testing - sending to user@gmail.com 2 Thread-Index: AcShaco6m1Vd7hEyRd2uGq7iZUf4ZA== Content-class: urn:content-classes:message From: "dmabe" <dmabe@domain.com> X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 To: <user@gmail.com> Test

Which perl module would you select to send this email using SMTP to a remote server?

Keep in mind the following comments:

Dave

Want a Free IPod?

Edit by castaway, swap pre tags for code tags, to help wrapping

Replies are listed 'Best First'.
Re: Sending emails from BSMTP formatted files
by sgifford (Prior) on Sep 23, 2004 at 16:21 UTC

    I think the best approach would be to simply parse this file and send the SMTP commands with Net::SMTP. Error handling isn't that hard; just check the return values from each of the commands. An easy way to handle these errors would be to use Perl's exception handling mechanism, eval and die.

    It looks like you're on your own figuring out what SMTP host to connect to. You'll have to parse the recipient address, then use DNS to figure out which host you should connect to, and back off to higher-distance MXs if the lower-distance ones fail. You may be able to find a module to do this; if you can't consider sharing this code, since it seems like it would be generally useful.

Re: Sending emails from BSMTP formatted files
by bageler (Hermit) on Sep 23, 2004 at 17:38 UTC
    Email::Simple will parse it for you very nicely.
    Mail::Sendmail is a good way to send mail.

    I suggest using http://search.cpan.org in the future.
Re: Sending emails from BSMTP formatted files
by waswas-fng (Curate) on Sep 23, 2004 at 16:27 UTC
    Seems silly to ask for help building a mass mailer, while you have a link to a spam email address harvester (freeipods.com) on your sig -- check out the wonderful terms from the site:

    ". Emails.
    (c) By signing up for this website, the user agrees to receive emails we or another 3rd party may send about special offers on our website, as well as third party advertisements or offers.
    ". Good luck.


    -Waswas