当前位置: 技术问答>linux和unix
使用perl发送带有附件的电子邮件是什么原理呀?不带附件得我已经发送成功了,希望指点
来源: 互联网 发布时间:2015-01-06
本文导语: 使用perl发送带有附件的电子邮件是什么原理呀?不带附件得我已经发送成功了,希望指点 (最好有简单代码) | 找到几个小例子,用MIME::Lite或者Mail::Sender use MIME::Lite; $msg = new MIME::Lite ...
使用perl发送带有附件的电子邮件是什么原理呀?不带附件得我已经发送成功了,希望指点
(最好有简单代码)
(最好有简单代码)
|
找到几个小例子,用MIME::Lite或者Mail::Sender
use MIME::Lite;
$msg = new MIME::Lite
From =>'me@myhost.com',
To =>'you@yourhost.com',
Cc =>'some@other.com, some@more.com',
Subject =>'A message with 2 parts...',
Type =>'multipart/mixed';
attach $msg
Type =>'TEXT',
Data =>"Here's the GIF file you wanted";
attach $msg
Type =>'image/gif',
Path =>'aaa000123.gif',
Filename =>'logo.gif';
$msg->send;
======================
use MIME::Lite;
$msg = MIME::Lite->new(
From=>'youremail@mailserver.com',
To => 'receiver@mailserver.com',
Subject=>'This is a test MIME message',
Type=>'multipart/mixed');
$msg->attach(Type =>'TEXT',
Data=> 'This is the message');
$msg->attach(Type =>'TEXT/HTML',
Data=> 'D:datafileperlscripts');
MIME::Lite->send('smtp', “your.smtpserver.com”,
Timeout=>60);
=============================
use Mail::Sender;
# Send Email Message
sub send_email {
$sender = new Mail::Sender( {from => $from_address});
$sender->OpenMultipart( {to => $to_email,
subject => $subject});
$sender->Body;
$sender->SendLine($msg_body);
$sender->SendFile(
{description => 'Raw Data File',
encoding => '7BIT',
file => $tempfile
});
$sender->Close;
} # end send_email
use MIME::Lite;
$msg = new MIME::Lite
From =>'me@myhost.com',
To =>'you@yourhost.com',
Cc =>'some@other.com, some@more.com',
Subject =>'A message with 2 parts...',
Type =>'multipart/mixed';
attach $msg
Type =>'TEXT',
Data =>"Here's the GIF file you wanted";
attach $msg
Type =>'image/gif',
Path =>'aaa000123.gif',
Filename =>'logo.gif';
$msg->send;
======================
use MIME::Lite;
$msg = MIME::Lite->new(
From=>'youremail@mailserver.com',
To => 'receiver@mailserver.com',
Subject=>'This is a test MIME message',
Type=>'multipart/mixed');
$msg->attach(Type =>'TEXT',
Data=> 'This is the message');
$msg->attach(Type =>'TEXT/HTML',
Data=> 'D:datafileperlscripts');
MIME::Lite->send('smtp', “your.smtpserver.com”,
Timeout=>60);
=============================
use Mail::Sender;
# Send Email Message
sub send_email {
$sender = new Mail::Sender( {from => $from_address});
$sender->OpenMultipart( {to => $to_email,
subject => $subject});
$sender->Body;
$sender->SendLine($msg_body);
$sender->SendFile(
{description => 'Raw Data File',
encoding => '7BIT',
file => $tempfile
});
$sender->Close;
} # end send_email