Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sendmail Attachment

Status
Not open for further replies.

wsexton

Technical User
Dec 4, 2001
49
0
0
US
I'd like to add an attachment to an email I'm sending from a perl script using sendmail. Here's my code:
#!/usr/bin/perl

use warnings;

use CGI;
use Mail::Sendmail;

$file = "testdoc.txt";

unshift @{$Mail::Sendmail::mailcfg{'smtp'}} , 'AB-MAIL4';

%mail = ( To => 'wsexton@anywhere.net',
From => 'DSU Request Form@anywhere.net',
);


$mail{'mESSaGE : '} = "This is my message.";

sendmail(%mail) or die $Mail::Sendmail::error;

I'd like to attach a file to this email, and I can figure out how it's done. Any help would be appreciated.
 
Easy module to use to send attachment without messing with converting it to a mime attachment yourself:

Code:
#!/usr/bin/perl -w
use strict;
use Mail::SendEasy ;
my $mail = new Mail::SendEasy( smtp => 'smtp.west.cox.net' ) ;
my $status = $mail->send(
  from    => 'kordaff@plh.org',
  from_title => 'Kordaff Nobleheart',
  to      => 'spam@plh.org',
  subject => "MAIL Test",
  msg     => "The Plain Msg...",
  html    => "<b>Me Pic</b><img src='[URL unfurl="true"]http://plh.org/images/phil.jpg'>",[/URL]
  anex    => "media/85064a6eb7b625690cd6daae96b60006200510020_full.jpg",
  );
if (!$status) { print $mail->error ;}

The anex method sends the file you've give the path to as an attachment. The html bit was me figuring out how to send a pic in the email. Got Mail::SendEasy from CPAN. It also does smtp auth.

Kordaff
 
I've tried using ppm to install Mail-SendEasy but I get the message "no suitable installation target found for package Mail-SendEasy." I'm using ActivePerl 5.8.7.813.
 
This module is pure perl, no .c or .xs files in it. I'm going to reboot to my trusty (heh) windows partition and see if I can locate a make.exe to install this there.

Kordaff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top