in reply to Re^2: Trouble emailing zip file
in thread Trouble emailing zip file
Unfortunately I don't have any of the email modules installed
Please see Yes, even you can use CPAN - if you can install Perl scripts on the server, then normally you can install modules there too, for example with local::lib.
Could you please post an example on how to encode the zip file into the temp file?
I initially thought that uuencode could write its output to a file, but I was mistaken, it apparently always writes to its standard output. Since I don't recommend qx//, capturing its output is not trivial - see the section "Use a Piped open" in that link for a way to do it with pure Perl. Alternatively, you don't have to shell out at all, since pack supports uuencoding - with thanks to the Perl Power Tools:
# takes one argument, the filename to encode # returns one value, the filename of the temporary(!) output file use File::Temp qw/tempfile/; sub uuencode { my ($infile) = @_; my ($tfh,$tfn) = tempfile(UNLINK=>1); open my $fh, '<:raw', $infile or die "$infile: $!"; printf $tfh "begin %03o %s\n", ((stat($infile))[2] & 0666)||0644, $infile; my $buf; print $tfh pack 'u', $buf while read $fh, $buf, 45; print $tfh "`\n", "end\n"; close $fh; close $tfh; return $tfn; }
That will return the filename of the temporary file that you can then pass to mailx - but make sure to use the "list" form of system, as I showed in the above link as well.
By the way, in your original post, you said mailx -r $recipient1 - but the -r option sets the From address. Are you sure you've got your mailx command right?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Trouble emailing zip file
by TonyNY (Beadle) on Jul 04, 2018 at 19:10 UTC | |
by Paladin (Vicar) on Jul 04, 2018 at 23:08 UTC | |
by poj (Abbot) on Jul 04, 2018 at 20:23 UTC | |
by TonyNY (Beadle) on Jul 04, 2018 at 22:32 UTC | |
by AnomalousMonk (Archbishop) on Jul 04, 2018 at 22:47 UTC | |
by haukex (Archbishop) on Jul 06, 2018 at 11:30 UTC |