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

Hey all, I'm currently putting together some email routing from an internal network to an external one. I want to keep the current sendmail.cf file and use an alternate for the sending of emails to go out over the internet. I'm somewhat familiar with Mail::Sender (a very cool module!!!) and can get it to do what I need as far as assembling a message for delivery. This would be simple, I think, if I were just sending a text body as the email and nothing else. But I will actually have users who will be sending attachments as well. What I need to do is, call Mail::Sender to assemble the email, and then have sendmail called with the alternate .cf file to deliver the message through our mail hub. I can get sendmail to use the alternate .cf file by using the -C flag... no problem. How do I use this in conjunction with Mail::Sender though? Is Mail::Sender capable of doing this on its own? Is there another mail module that will do what I need? I'm currently going through the documentation on Mail::Sender... but I'm just impatient I guess. Thanks to all in advance for any help you can provide. Bradley
Where ever there is confusion to be had... I'll be there.

Replies are listed 'Best First'.
Re: Using an alternate sendmail.cf file
by Sinister (Friar) on Jul 13, 2001 at 17:35 UTC
    I think I would just open a pipe to sendmail en put in the stuff. For attachments you can mime encode your self and send a self constructed multipart message. This isn't to hard.

    Something like this:

    #!/usr/bin/perl use MIME::Base64; my $fullname = "Webmaster 2organize.com"; my $username = "webmaster"; my $hostname = "2organize.com"; my $my_config_file = "config"; my $from = "$fullname <$username\@$hostname>"; my $bound = "e7e0ec52ed9c9026a8e3f293d87abe92"; open (MAIL,"|sendmail -C $my_config_file") || Error("Couldn't open pip +e to mal injector\n"); print MAIL "Content-Type: multipart/mixed; boundary=\"$bound\"\n"; print MAIL "From: $from\n"; print MAIL "To: $to\n"; print MAIL "Bcc: $bcc\n"; print MAIL "Subject: Online vacature voor $app\n\n"; print MAIL "$mail_body\n"; foreach my $file (@ARGV) open(FILE,"<$file) || die("Couldn't open $file!\n"); seek (FILE, 0, 0); my $content = ""; while (<FILE>) { $content .= $_; } print MAIL "\n--$bound\n"; print MAIL "Content-type: $type{ExtGetter($file)}\n"; print MAIL "Content-Disposition: attachment; filename=\"$filename\"\ +n"; print MAIL "Content-Transfer-Encoding: base64\n\n"; print MAIL encode_base64($content); print MAIL "\n"; }


    Of course this untested and serves merely as an example

    Sinister greetings.
    perldoc -q $_
Re: Using an alternate sendmail.cf file
by rogueFalcon (Beadle) on Jul 13, 2001 at 20:19 UTC
    I am working on a similar project concerning mail and attachements. After several days of reading and posting and reading and posting. I have determined that MIME::Tools is the best module for handling attachments. It took me a couple of days to figure everything out.

    I am writing a simple (compared to the whole project) script that will check a POP3 Account and save the attachements seperatly from a message. I will post it here when I get it finished. Maybe it will help you.

    -- rogueFalcon

    Why do you people insist on doing things sdrawkcab?