#!/usr/bin/perl


use Jcode;
use MIME::Lite;


$subject = jcode($subject)->mime_encode();
$message = jcode($message)->jis;


#まずコンテナを作成
my $msg = MIME::Lite->new(
　　From => "$mailfrom",
　　To => "$mailto",
　　Bcc => "$bcc",
　　Subject => "$subject",
　　Type => 'multipart/mixed'
);


#メッセージ部分
$msg->attach(
Type => 'text/plain; charset="iso-2022-jp"',
Data => "$message"
);


#添付ファイル部分。添付ファイルをパスで示す場合はPath => を使用します。
$msg->attach(
Type => 'application/octet-stream',
Data => "$attachment",
Filename => "$filename",
Disposition => 'attachment'
);



===

my $msg = new MIME::Lite(
                         From=>'hoge@mytools.net'
                       , To=>'bar@mytools.net'
                       , Encoding=>'binary'
                       , Type=>'multipart/xxx'
                        );

### テキスト部の追加
$msg->append(
             Type=>'TEXT'
           , Data=>'添付するよん〜'
             );

### 添付ファイル
$msg->append(
             Type=>'binary'
           , Content-type=>'application/octet-stream'
           , Encoding=>'Base64'
           , File=>'/foo/bar/attach.file'
           , Name=>'attach.file'
             );

open(MAIL, "/usr/lib/sendmail -t") || die $!;
$msg->print(\*MAIL);
close(MAIL);


#!/usr/bin/perl -w
#-------------------------------------------------------------------------------
# $Id: attachement.html,v 1.1 2006/05/17 04:17:56 kishi Exp kishi $ 
# ファイルを添付してメール送信する
# Net::SMTPモジュールがインストールされていることを前提にしています。
#-------------------------------------------------------------------------------

use strict;
use MIME::Base64;
use MIME::Lite;
use Jcode;

if( $#ARGV + 1 != 1 ){
	print STDERR "Usage: $0 [FileToBeAttached]" . "\n";	
	exit -1;
}
my $file = $ARGV[0];

my $smtpserver = "ns.solmac.co.jp";
my $From ='mail-sender@solmac.co.jp';
my $To = 'admin@solmac.co.jp,pig-man@solmac.co.jp';
my $subject = "本日のレポート";
my $body = "本メールにファイルを添付しておりますので、宜しくお願い致します。";

Jcode::convert(\$subject, "jis");
$subject = '=?ISO-2022-JP?B?' . encode_base64($subject, '') . '?=';
Jcode::convert(\$body, 'jis');

my $msg = new MIME::Lite 
	From    =>$From,
	To      =>$To,
	Subject =>$subject,
	Type    =>'TEXT',
	Data    =>$body;

#
# ファイルを添付する
#
attach $msg 
	binmode => 1,	
	Type     =>'application/octet-stream',
	Path     =>$file,
	Encoding =>'base64',
	Filename =>$file;

MIME::Lite->send('smtp', $smtpserver, Timeout=>60);

$msg->send;
