I'm trying to use Mail::Sender to send a file, but I have to give Mail::Sender the full path of the file (because the Perl program will be run by cron), which is 90 characters. Is there a limit on the number of characters in the filename to attach?

I'm actually using programa.pl to call programb.pl, where programb.pl returns the path of the file to attach in programa. Like this:

$output=`perl /somewhat/long/path/here/and/there/programb.pl -option`;

After the command call, I simply change $output to an array, then scan for the text 'Filename=/home/blah/perl/foo/file.xls'.

Both do 'use Mail::Sender' but programb.pl does not create an instance (like $sender=new Mail::Sender()) because I have an option for programb that does not create an email. I thought programb.pl might be clobbering something in programa.pl.

I keep getting this error from Mail::Sender: 'Server error: 500 command unrecognized'. The command send is 'QUIT'. The bottom of the mail log is

<< --Message-Boundary-by-Mail-Sender-1417619876--
<< 
<< .
>> 250 P3HY1p00h2AhH0801 mail accepted for delivery
<< QUIT
>> 500 command unrecognized
<< quit
The section of code I'm using is:
if (len($fnout)>0)
    {
    if (-e $fnout) # If $fnout exists then send email.
        {
        @a=split('/',$fnout);
        $fn=$a$#a; # Drop directories from $fnout.
        $resultds=0;

        # Was $resultds=$senderds->MailFile(...)
        $s="$procname: Sending email to $to...";
        #debugpr($s,$prefixsp);
        # You can also use cc=>'comma,sep,list'
        # Also bcc=>'comma,sep,list'
        $resultds=$senderds->MailFile(
            {
            debug=>$logfn, # Debug/log file
            debug_level=>4,
            client=>'xxxclient',
            smtp=>$smtpserver,
            port=>80,
            from=>$user,
            authid=>$user,
            authpwd=>$pw,
            auth=>'LOGIN',
            to=>$to,
            msg=>$body,
            subject=>$subjparam,
            file=>$fnout
            });
        #if (($resultds<0) and ($resultds != -5))
        if (($resultds<0) )
            {
            $s=$prefixsp."$procname ERROR: ".
                "$resultds on MailFile(): '".
                trim($Mail::Sender::Error)."'\n";
            writeerr($s);
            $senderds->Close(); # Close on error.
            writeerrfile('all');
            exit 1;
            }

        } # if -e fnout
    else {
        $s=$prefixsp."$procname ERROR: $fnout does not exist.";
        writeerr($s);
        $senderds->Close();
        writeerrfile('all');
        exit 1;
        }
    }

The mail gets sent but it never has the attachment. I'm trying to get a PAUSE id so I can report this as a bug on CPAN.

Thanks!


In reply to Limit on attached filename for Mail::Sender? by bulrush

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.