Alternately, if you wanted to send the file as and attachment, you could do:#!/usr/bin/perl -w use strict; use Mail::Sender; # How these are defined is left as an exercise to the reader my ($from, $to, $subject, $message, $file, $server); # Create our message handler ref (my $mail = new Mail::Sender { smtp => $server } ) or die "Mail er +ror: $Mail::Sender::Error\n"; # Message header $mail->Open({ from => $from, to => $to, subject => $subject }) or die +"Mail error: $Mail::Sender::Error\n"; $mail->Body; # Add the "intro" message $mail->SendLineEnc("$message\n"); # Open $file, adding contents to message open(FILE, "$file"); while(<FILE>) { $mail->SendLineEnc("$_\n"); } # Close & send message $mail->Close;
instead of opening and reading the file.$mail->Attach({ description => 'Programming Perl 101 Syllabus', ctype => 'text/plain', encoding => '7bit', disposition => 'attachment; filename="syllabus.txt"; t +ype="Text file"', file => 'syllabus.txt' } );
In reply to Re: Sending email from a file.
by ibanix
in thread Sending email from a file.
by DigitalKitty
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |