[問題]利用Gmail寄信模組無法連線smtp server

看板Perl作者 (kkk)時間9年前 (2015/09/21 11:07), 9年前編輯推噓1(102)
留言3則, 1人參與, 最新討論串1/1
最近試著利用模組Email::Send::SMTP::Gmail寄信 但是當我將smtp server設定成smtp.gmail.com會無法將信件寄出 會出現錯誤訊息: Connecting to smtp.gmail.com using tls with LOGIN on port 587 and timeout of 60 Could not connect to SMTP server Can't locate object method "send" via package "Net::SMTPS: connect: Network is unreachable" (perhaps you forgot to load "Net::SMTPS: connect: Network is unreachable"?) at gmail.pl line 22. 但是當我將smtp server改成ip時就可運作 我確認我主機有設定dns,可用nslookup指令正解域名 我的主機OS是CentOS 6.7 程式碼如下: #!/usr/bin/perl -w # use warnings; use Email::Send::SMTP::Gmail; @test=("aaaaaa","bbbbbbbbbbbbb","ccccccc"); my $mail=Email::Send::SMTP::Gmail->new( -smtp=>'smtp.gmail.com', # -smtp=>'64.233.189.109', -login=>'xxxxx@xxxxxx', -pass=>'xxxxxx', -port=>'587', -verbose=>1, -debug=>1 ); $mail->send(-to=>'xxxxx@xxxxx', -subject=>'gmailtest', -body=>"@test", -verbose=>1,-debug=>1 ); 請問為什麼會有這種情形?我該如何解決? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 210.240.195.8 ※ 文章網址: https://www.ptt.cc/bbs/Perl/M.1442804850.A.363.html ※ 編輯: mate99 (210.240.195.8), 09/21/2015 13:59:14

09/21 19:33, , 1F
基本的建議是google說明看了嗎 https://goo.gl/3kPFzR
09/21 19:33, 1F

09/21 19:33, , 2F
http://goo.gl/ikNGqY 說的 套件相依性解決了嗎, 物件(就
09/21 19:33, 2F

09/21 19:35, , 3F
是 $mail)產生成功了嗎, verbose的debug用 錯誤訊息是什麼
09/21 19:35, 3F
一樣的程式碼新裝的centos6.7不能用在centos5.10同樣的安裝模組方式是可以運作 後來在centos 6.7我試著利用cpanp將IO::Socket::INET6這個模組裝一遍就可以運作了, 原因是甚麼我也不清楚,總之是可以用了。 ※ 編輯: mate99 (114.35.46.18), 09/22/2015 14:02:16
文章代碼(AID): #1L_tHoDZ (Perl)
文章代碼(AID): #1L_tHoDZ (Perl)