Entry
How to attach a file to a mail with sendmai or other ?
Besides using a module eg. Mail::Sender, can I use the server's sendmail program to attach files? An
Jun 16th, 2000 07:49
Marco Steinacher, Kirederf, Nazar Wahab, http://cpan.valueclick.com/modules/by-category/19_Mail_and_Usenet_News/Mail/
You can do this with the Module Mail::Sender.
You can get the Module Mail::Sender at CPAN (see sources), if it isn't
installed on your system yet.
You can view the documenation with "perldoc Mail::Sender".
Example:
********
# This example will send the file "/tmp/somefile.vbs" to
# myfriend@websource.ch and a copy to myotherfirend@websource.ch and
# mythirdfriend@websource.ch with the subject "A file for my friends"
# and the message-body "Hello friends.\n\nPlease open this file.\n",
# using the SMTP-Host smtp.websource.ch and the From-Adress
# 'sales@websource.ch (WebSource - Sales)'.
use Mail::Sender;
# Prepare Mailer
$sender = new Mail::Sender
{smtp => 'smtp.websource.ch', from => 'sales@websource.ch
(WebSource - Sales)'};
$err = $Mail::Sender::Error;
if ($err) die $err; # Terminate on error.
# Prepare message
$sendto="myfriend@websource.ch";
$copys="myotherfriend@websource.ch,mythirdfriend@websource.ch";
$subject="A file for my friends";
$message="Hello friends.\n\nPlease open this file\n";
$file="/tmp/somefile.vbs";
# Send the mail
$sender->MailFile({to => $sendto,
cc => $copys,
subject => $subject,
msg => $message,
file => $file});
$err = $Mail::Sender::Error;
if ($err) die $err; # Terminate on error.