[問題] Net::SMTP::SSL 模組寄信的問題

看板Perl作者 (波哥)時間15年前 (2010/05/06 18:21), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/5 (看更多)
小弟最近使用Perl 的Net::SMTP::SSL模組 寫寄信的程式, 主要的目的是要在命令列模式下透過gmail server 把信給寄出去。 程式碼可以正常執行無任何錯誤訊息跑出。 但是,信箱就是沒有 收到寄過來的信,不曉得原因是發生在那裡?! 程式碼如下: #!/usr/bin/perl use warnings; use strict; use Net::SMTP::SSL; my $user = 'my9423504@gmail.com'; my $pass = 'n123'; my $server = 'smtp.googlemail.com'; my $to = 'u9423504@yuntech.edu.tw'; my $from_name = 'james'; my $from_email = 'my9423504@gmail.com'; my $subject = 'smtp-ssl-auth test'; my $smtps = Net::SMTP::SSL->new($server, Port => 465, DEBUG => 1, ) or warn "$!\n"; # I just lucked out and this worked for auth (yeah inheritance :-) ) defined ($smtps->auth($user, $pass)) or die "Can't authenticate: $!\n"; $smtps->mail($from_email); $smtps->to($to); $smtps->data(); $smtps->datasend("To: $to\n"); $smtps->datasend(qq^From: "$from_name" <$from_email>\n^); $smtps->datasend("Subject: $subject\n\n"); $smtps->datasend("This will be the body of the message.\n"); $smtps->datasend("\n--\nVery Official Looking .sig here\n"); $smtps->dataend(); $smtps->quit(); print "done\n"; -- 波哥IT私房菜: http://i-pogo.blogspot.com/ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.117.126.25 ※ 編輯: u9423504 來自: 122.117.126.25 (05/06 18:22) ※ 編輯: u9423504 來自: 122.117.126.25 (05/06 18:26)
文章代碼(AID): #1BufWDtf (Perl)
文章代碼(AID): #1BufWDtf (Perl)