encoding perl msg

M

mike

I am trying to attach an ms word doc to a perl message using:

use MIME::Lite;

Here are the parts of the code I an wondering about:

# The base path to the hbdata files
my $filebase = "/home/blah";

# The file fully qualified
my $attch_file = "$filebase/some.doc";

#who the email is being sent to
my $To = "somebody\@theirplace.com";

# To and From email addresses
my $from = "somewhere\@myplace.com";

my $mymsg = "test";

my $msg = new MIME::Lite
From =>$from,
To =>$To,
Subject =>'a subject',
Type =>'multipart/mixed',
Data =>"$mymsg";

attach $msg
Type =>'application/msword doc',
Disposition =>'attachment',
Encoding =>'binary',
Path =>$attch_file;

$msg->send;

This gets sent but the document is not recognized properly when I open
the attachment.

I deleted the line: Encoding =>'binary',

figuring the application would figure it out by itself and it did.

However, what should " Encoding =>'', " be?

Any reponses are appreciated.

Mike
 
B

Brian Wakem

mike said:
I am trying to attach an ms word doc to a perl message using:

use MIME::Lite;
Type =>'application/msword doc',
Disposition =>'attachment',
Encoding =>'binary',
Path =>$attch_file;

$msg->send;

This gets sent but the document is not recognized properly when I open
the attachment.

I deleted the line: Encoding =>'binary',

figuring the application would figure it out by itself and it did.

However, what should " Encoding =>'', " be?

Any reponses are appreciated.

Mike


The documentation of the module you are using says:

$MIME::Lite::AUTO_ENCODE
If true, automatically choose the encoding from the content type. Default is
true.

So you don't need to bother adding the Encoding type in most cases.
 
M

mike

Bummer ... I just found out that the message contents in $mymsg are not
getting picked up.
 
B

Brian McCauley

mike said:
Subject: encoding perl msg

In this newsgroup the fact that (you think that) Perl is relevant is
implicit. So your subject should be "encoding MIME message".

Anyhow I don't think you were right in supposing your question was
related to Perl.
I am trying to attach an ms word doc to a perl message using:

No, you mean MIME message.
my $msg = new MIME::Lite
From =>$from,
To =>$To,
Subject =>'a subject',
Type =>'multipart/mixed',
Data =>"$mymsg";

attach $msg
Type =>'application/msword doc',
Disposition =>'attachment',
Encoding =>'binary',
Path =>$attch_file;

$msg->send;

This gets sent but the document is not recognized properly when I open
the attachment.

I deleted the line: Encoding =>'binary',

figuring the application would figure it out by itself and it did.

However, what should " Encoding =>'', " be?

Most transport mecahisms won't handle raw binary encoding. You should
usually use base64 to encode binary data.
Any reponses are appreciated.

By the way, did I mention this has nothing at all to do with Perl?
 
B

Brian Wakem

mike said:
Bummer ... I just found out that the message contents in $mymsg are not
getting picked up.


Well I know why, but as you haven't quoted anything, I have nothing to quote
in my reply.
 
M

mike

I got it ..... ( sheepishly ... ) I looked at the docs ..

http://www.akadia.com/services/email_attachments_using_perl.html

Since I was using multi part docs I needed a separate attach section
like:

my $msg = new MIME::Lite
From =>$from,
To =>$To,
Subject =>'subject',
Type =>'multipart/mixed';

attach $msg
Type =>'text/html',
Data =>$mymsg;

attach $msg
Type =>'application/msword doc',
Disposition =>'attachment',
Path =>$attch_file;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top