0

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

我遇到的问题是我正在发送csv带有 some 的文件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;
4

0 回答 0