Hi,
I am using the script below to send a mail.
How can I attach a file? And I don't want to install anything on my server.
Or maybe there is another way to do this without the scrip below...
Thank you.
use Net::SMTP;
die ("Usage: sendmail.pl <smtpserver> <from> <to> <subject> <msgfilename>") if ($#ARGV != 4);
$smtpserver = $ARGV[0];
$sender = $ARGV[1];
$recipient = $ARGV[2];
$subject = $ARGV[3];
$msgfilename = $ARGV[4];
$smtp = Net::SMTP->new($smtpserver);
$smtp->mail($sender);
$smtp->to($recipient);
$smtp->data();
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("To: $recipient\n");
$smtp->datasend("\n");
open (MESSAGE, $msgfilename) || die "cannot open message file $msgfilename.";
@nachricht=<MESSAGE>;
close MESSAGE;
foreach $zeile (@nachricht) {
$smtp->datasend("$zeile");
}
$smtp->dataend();
$smtp->quit;
You can attach using the module you're using.
$smtp->datasend("MIME-Version: 1.0\n");
$smtp->datasend("Content-Disposition: attachment; filename=\"/a/path/to/file.txt\"\n");
$smtp->datasend("Content-Type: application/text; name= attachment.txt ");
$smtp->datasend();
Here is a short guide how to send html mail via service console.
If you found this information useful, please consider awarding points for "Correct" or "Helpful". Thanks!!!
Regards,
Stefan Nguyen
iGeek Systems LLC.
VMware, Citrix, Microsoft Consultant