Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Limit on attached filename for Mail::Sender?

by bulrush (Scribe)
on Dec 03, 2014 at 15:22 UTC ( [id://1109123]=perlquestion: print w/replies, xml ) Need Help??

bulrush has asked for the wisdom of the Perl Monks concerning the following question:

  • Perl 5.18 on Ubuntu 14.04LTS.
  • Mail::Sender v0.8.23 (the latest)
  • A Google search didn't get me anywhere.
  • The Mail::Sender module uses the Perl 'open' command if that matters.
  • I'm in a testing phase right now so I'm not using cron, but that's the final idea. I'm running programa.pl from the command line right now.
  • I'm using Godaddy as a SMTP account provider if that matters. I had quite a bit of trouble getting Mail::Sender to work in July 2014. I tried 5 examples from Mail::Sender alone and none of them worked. I also tried another 3 modules to send email.

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!

  • Comment on Limit on attached filename for Mail::Sender?

Replies are listed 'Best First'.
Reporting bugs
by hippo (Bishop) on Dec 03, 2014 at 15:49 UTC
    I'm trying to get a PAUSE id so I can report this as a bug on CPAN.

    That isn't necessary as the RT home page explains. You will need a Bitcard or OpenID account if you wish to use the web interface to report a bug in a module. Either of those will be faster to obtain than a PAUSE account (and useful in a wider number of places into the bargain). But of course, you can always use the email interface to report a bug without any account at all.

Re: Limit on attached filename for Mail::Sender?
by choroba (Cardinal) on Dec 03, 2014 at 15:48 UTC
    Shouldn't you provide the full path to perl as well in cron?
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: Limit on attached filename for Mail::Sender?
by RichardK (Parson) on Dec 03, 2014 at 16:41 UTC

    Have you checked the file permissions?

    When things go wrong in a cron job it's often a permissions problem, usually the cron job is running as a different user and can't access the file.

      I'm still in a testing phase and I'm not using cron yet. I'm running programa.pl from the command line, and in programa.pl and programb.pl I do check for the existence of the file to attach before continuing. Both those file existence checks pass.

      Besides, when I run programa.pl at the command line, I'm a logged in user 'chuck', so the owner of the created XLS file is also 'chuck'. So permissions should not be an issue.

      Anyway the file permissions on the XLS file created by programb.pl is: -rw-rw-rw-.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1109123]
Approved by stevieb
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-25 12:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found