⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ssendmail.pm

📁 稀饭伊人相册系统继承了新天堂多用户相册系统的功能
💻 PM
字号:
#2006.8.4
#邮件发送模块,可发送附件
sub send_mail
{
# my ($self,$mailTo,$subject, $content, $attachmentRef) = @_;
use Net::SMTP;
use MIME::Lite;
#预发送的邮件地址,邮件标题,内容,附件
my ($mailTo,$subject, $content, $attachmentRef)=@_;
my @mailto;

if   ($mailTo=~ /ARRAY/) {@mailto=@$mailTo;}
elsif($mailTo=~ /SCALAR/){@mailto=$$mailTo;}
else {@mailto=%$mailTo;}

my $mailFrom = $conf{mailFrom};
my $mailhost = $conf{mailhost}; # the smtp host

my $smtp = Net::SMTP->new($mailhost, Hello => 'localhost', Timeout => 30, Debug => 0)||die 'Cannot connect to server';

# 邮件服务器登录验证, type your user name and password here
$smtp->auth($conf{CUser},$conf{CPass});



foreach my $mailto (@mailto) {
       # Create a new multipart message:
        my $msg = MIME::Lite->new(
        From    => $mailFrom,
        To      => $mailTo,
        Subject => $subject,
        Type    =>'multipart/mixed')or print "Error creating MIME body: $!\n";

      # Add parts:
            $msg->attach(Type =>'TEXT',
                         Data =>$content,
                         );
        #添加附件
        if($attachmentRef)
        {
         my @attachment = @$attachmentRef;
         foreach my $attachment (@attachment)
         {
          $msg->attach(
          Type     => 'AUTO',      # the attachment mime type
          Path     => $attachment, # local address of the attachment
                     )or print "Error attaching file: $!\n";
         }
        }
        my $str = $msg->as_string() or print "Convert the message as a string: $!\n";
        # Send the From and Recipient for the mail servers that require it
        $smtp->mail($mailFrom);
        $smtp->to($mailto);
        # Start the mail
        $smtp->data();
        $smtp->datasend("$str");
        # Send the termination string
        $smtp->dataend();
                               }

$smtp->quit;
}
1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -