通过perl脚本发送的电子邮件附件文件出错

时间:2013-08-28 19:55:56

标签: perl email window smtp mime-mail

我正在使用此script使用perl发送带附件的电子邮件

我遇到的问题是我发送的csv文件有一些formatting,发送部分运行良好而没有任何错误但是当我收到电子邮件时,附件没有格式化有趣的人物。

屏幕显示我发送的文件 - http://imgur.com/Gkkz26W
屏蔽我收到的文件 - http://imgur.com/UMlXp3F

任何人都明白为什么会这样?

#!/usr/bin/perl

use MIME::Lite;
use Net::SMTP;

### Adjust sender, recipient and your SMTP mailhost
my $from_address = 'martin dot zahn at akadia dot ch';
my $to_address = 'martin dot zahn at akadia dot ch';
my $mail_host = 'mailhost.domain.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_csv = 'my_file.csv';
my $your_file_csv = 'your_file.csv';

### 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 CSV file
$msg->attach (
   Type => 'text/csv',
   Path => $my_file_csv,
   Filename => $your_file_csv,
   Disposition => 'attachment'
) or die "Error adding $file_csv: $!\n";

### Send the Message
MIME::Lite->send('smtp', $mail_host, Timeout=>60);
    $msg->send;

0 个答案:

没有答案