[問題]使用Net::SMTP::SSL寄信亂碼的問題
小弟使用Net::SMTP::SSL的模組寫寄信的程式,
程式可以正常的執行無誤,但是發現有些信箱收信正常(如gmail、msn hotmail),有些
信箱收箱卻有亂碼的情況發生(如pchome)。
以下是完整程式碼:
#!/usr/bin/perl
use Net::SMTP;
use MIME::Lite;
use Net::SMTP::SSL;
# setting
my $mailhost = 'smtp.gmail.com';
my $username = 'my9423504@gmail.com';
my $password = 'n123';
my $from = 'my9423504@gmail.com';
my $to = 'music_folk@pchome.com.tw';
my $subject = '中文測式'; # mail title
my $content = '郵件測式'; # the content of email
my $attachment = '/home/james/1.jpeg';
my $attachment2='/home/james/json.txt';
$smtp = Net::SMTP::SSL->new($mailhost,
Port => 465, Timeout => 120, Debug => 1);
# anth login
$smtp->auth($username, $password);
my $msg = MIME::Lite->new(
From => $from,
To => $to,
Subject => $subject,
Type => 'TEXT',
Data => $content,
);
# Attach
$msg->attach(
Type => 'image/gif', # the attachment mime type
Path => $attachment, # local address of the attachment
Filename => 'jpeg', # the name of attachment in email
);
$msg->attach(
Type => 'text', # the attachment mime type
Path => $attachment2, # local address of the attachment
Filename => 'jason', # the name of attachment in email
);
my $str = $msg->as_string() or die "Convert the message as a string: $!\n";
$smtp->mail($from);
$smtp->to($to);
$smtp->data();
$smtp->datasend($str);
$smtp->dataend();
$smtp->quit;
--
波哥IT私房菜: http://i-pogo.blogspot.com/
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.117.126.25
推
05/11 20:44, , 1F
05/11 20:44, 1F
Perl 近期熱門文章
PTT數位生活區 即時熱門文章