[問題]使用Net::SMTP::SSL寄信亂碼的問題

看板Perl作者 (波哥)時間15年前 (2010/05/10 18:39), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/1
小弟使用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
why not use Email::Send::Gmail? see post 1997
05/11 20:44, 1F
文章代碼(AID): #1Bv-9fM1 (Perl)
文章代碼(AID): #1Bv-9fM1 (Perl)