【发布时间】:2018-03-28 02:27:41
【问题描述】:
use warnings;
use MIME::Lite;
use Net::SMTP;
### Adjust sender, recipient and your SMTP mailhost
my $from_address = 'doni@home.com';
my $to_address = 'doni@home.com';
my $mail_host = 'smtp.office365.com';
### Adjust subject and body message
my $subject = 'A message with 2 parts ...';
my $message_body = "Here's the attachment file(s) you wanted";
### Adjust the filenames
my $my_file_txt = 'C:\Users\Doni\Documents';
my $your_file_txt = 'test1.txt';
### Create the multipart container
$msg = MIME::Lite->new (
From => $from_address,
To => $to_address,
Subject => $subject,
Type =>'multipart/mixed'
) or die "Error creating multipart container: $!\n";
### Add the text message part
$msg->attach (
Type => 'TEXT',
Data => $message_body
) or die "Error adding the text message part: $!\n";
### Add the TEXT file
$msg->attach (
Type => 'text',
Encoding => 'base64',
Path => $my_file_txt,
Filename => $your_file_txt,
Disposition => 'attachment'
) or die "Error adding file_text: $!\n";
##Send
MIME::Lite->send('smtp',$mail_host,SSL=>0,AuthUser=>'doni@home.com',AuthPass=>'******',Debug=>1,Port=>587,Timeout=>60);
$msg->send;
命令的输出是:
##Here's the output
SMTP auth() command not supported on smtp.office365.com
如何解决这个问题?我被困住了。
【问题讨论】: