Hi all.
I´m sending attachments with the following code:
(it works ok with mailserver running MS Exchange, and other mailservers too)
###################################
#!/usr/bin/perl

use MIME::Lite;

use strict;

my $subject = "Here goes the subject";

my $attachfile = "File_to_Attach";

my $msg = new MIME::Lite (
              From    =>'[EMAIL PROTECTED]',
              To      =>'[EMAIL PROTECTED]',
              Cc      =>'[EMAIL PROTECTED]',
              Subject =>$subject,
              Type    =>'multipart/mixed');

$msg->attach(
            Type     =>'TEXT',
            Data     =>$subject);

$msg->attach(
            Type     =>'TEXT',
            Path     =>$attachfile,
            Filename =>$attachfile);

$msg->send();
##########################################
Let me know if it works for you... :)
Bye
Ricardo Derbes
Altec SE
Albarracín 157 - San Carlos de Bariloche
+54-2944-426892
[EMAIL PROTECTED]
----- Original Message -----
From: "Mike Rapuano" <[EMAIL PROTECTED]>
To: "Mike Rapuano" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Thursday, August 23, 2001 4:17 PM
Subject: RE: Sending emails: Question <newbie>


HI --

Has anyone had a similar problem when sending email with attachments??

Thanks

Mike


-----Original Message-----
From: Mike Rapuano
Sent: Thursday, August 23, 2001 2:07 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; Mike Rapuano
Subject: Sending emails: Question <newbie>


Hi all --

I'm trying to send an email with an attachment from the below code (Gary
MacDonald posted the code on activestate. Thanks Gary:-). The code works
fine to send email to my Imail Server (type of nt mail server) but when
I try to send a message to either ny yahoo mail account or my exchange
mail server "I don't get the body of the message OR the attachment".

Any suggestion would be greatly appreciated.

Thanks

Mike





use Net::SMTP;
use MIME::Base64;


my $file = 'test.doc';
my $mediatype = 'msword';
open INPUT, $file or die "Can't open INPUT file $file: $!\n";
binmode INPUT;
my $buffer;
#
my $from = '[EMAIL PROTECTED]';
my $to = '[EMAIL PROTECTED]';
my $server = 'smtp.server.com';

#
my $smtp = Net::SMTP->new($server) or die "Can't create SMTP object\n";
#
$smtp->mail($from);
$smtp->to($to);
#
my @msg = <<MSG;
From: $from
To: $to
Subject: word document attachment
MIME-Version: 1.0
Content-type: multipart/mixed; boundary="Boundary $time"

--Boundary $time
Content-type: text/plain

This is a test email.....


--Boundary $time
Content-type: application/$mediatype; name="$file"
Content-disposition: attachment; filename="$file"
Content-transfer-encoding: base64

MSG


#
$smtp->data();
$smtp->datasend(@msg);
$smtp->datasend(encode_base64($buffer)) while(read (INPUT, $buffer,
60*57));
$smtp->datasend("\n--Boundary $time--\n");
$smtp->dataend();
$smtp->quit();
#
close INPUT;




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to