SendMail Attachement Name

50 views
Skip to first unread message

sangee...@gmail.com

unread,
Nov 26, 2008, 12:51:46 AM11/26/08
to Perl Mail::Sendmail
When I am trying to use sendmail, and attach a file with it, for some
reason the attachment in the email has the full path of the file as
the name of the file.

So if my file is /tmp/abc.txt, when i attach this file, the name of
the file comes as /tmp/abc.txt. I would like the name to be something
else, like only abc.txt, and not the entire path.

Here is the code that I have at my end:

$file="/tmp/abc.txt";
$fileName="abc/txt";
if ($isFileAttached)
{
open (F, $file) || print LOGFILE "Failed to read $file: $!\n";
binmode F; undef $/;
$mail{body} = encode_base64(<F>);
close F;
}

$message
$boundary
Content-Type: application/$attachmentType; name="$file"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="$fileName"


Even though i have named the filename paramter as $fileName which is
abc.txt, it shows up as the entire path..
Reply all
Reply to author
Forward
0 new messages