Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: mail script with attachment

by atcroft (Abbot)
on Jan 16, 2012 at 23:52 UTC ( #948229=note: print w/replies, xml ) Need Help??

in reply to mail script with attachment

The problem that appears to be occurring is that you are Base64 encoding the file name, rather than the content of the file. This is illustrated by decoding the value that appeared in the email:

$ perl -MMIME::Base64 -le 'print decode_base64(q{MTAwMWR1LnR4dA==});' 1001du.txt

MIME::Base64's documentation does not indicate that it can open a file on its own, but instead encodes the stream of bytes it is given as its first argument.

Hope that helps.

Replies are listed 'Best First'.
Re^2: mail script with attachment
by zlinkexchange (Initiate) on Jan 17, 2012 at 00:44 UTC
    This is what I get when using the $line variable and not the $file variable. I merely switched the two:
    Content-Transfer-Encoding: binary Content-Type: multipart/mixed; boundary="boundary-111916012012" MIME-Version: 1.0 Date: 111916012012 From: To: Subject: New loan request in database (extra fields) This is a multi-part message in MIME format. --boundary-111916012012 Content-Disposition: inline Content-Length: 271 Content-Transfer-Encoding: binary Content-Type: text/plain Dear Member, Please find attached to this email message a loan application file from a recent loan applicant. Be sure to save this DU 3.2 file to you +r hard drive and import the data into your loan processing program. Regards, Site Administration --boundary-111916012012 Content-Disposition: inline; filename="1033du.txt" Content-Transfer-Encoding: base64 Content-Type: application/zip; name="1033du.txt" MTAzM3x8fFNjb3R8c2tpbmdAbW9ydGdhZ2UtcHJvcy5jb218WWVzfFl8fHx8fDF8fDM2MH +x8fHx8 fHx8fHx8fHx8fHx8fHx8fHx8fHxTY290fEN8S2luZ3x8fHx8fGFzZGZ8NTY1NDY1NDY1NH +x8fDE2 NTQxMTIzfDV8fHx8fHx8fHx8fHx8MTIzIEFueSBTdHJlZXR8fEFueSBDaXR5fENBfDEyMz +Q1fHx8 fFl8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8Z3x8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fH +x8fHx8 fHx8fHNhZGZ8fHx8fHx8fHx8fDU2NDU2NTU1fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fH +x8fHx8 fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fH +x8fHx8 fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fH +x8fHx8 fHx8fHx8fHx8fHx8fHxZfFl8fHx8fHx8fHx8fHx8fHx8fHx8fHx8YXBwfHx8U3VibWl0IE +FwcGxp Y2F0aW9ufHw= --boundary-111916012012--

      But, where is $line defined?

      See $/ to slurp the file in a variable

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://948229]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2018-06-25 04:49 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.