我寫了一個perl腳本使用Gmail的SMTP服務器發送電子郵件驗證失敗:smtp.gmail.com -(Perl的淨:: SMTP)使用Gmail的SMTP服務器
use Net::SMTP;
my $smtp = Net::SMTP->new('smtp.gmail.com',
Port=> 587,
Timeout => 20,
Hello=>'[email protected]'
);
print $smtp->domain,"\n";
$sender = "[email protected]";
$password = "mypassword";
$smtp->auth ($sender, $password) or die "could not authenticate\n";
$receiver = "[email protected]";
$subject = "my custom subject";
$smtp->mail($sender);
$smtp->to($receiver);
$smtp->data();
$smtp->datasend("To: <$reciever> \n");
$smtp->datasend("From: <$sender> \n");
$smtp->datasend("Content-Type: text/html \n");
$smtp->datasend("Subject: $subject");
$smtp->datasend("\n");
$smtp->datasend('the body of the email');
$smtp->dataend();
$smtp->quit();
print "done\n\n";
對於 '用戶',我有我的Gmail用戶名和'mypassword'我有密碼。但是當我運行這段代碼時,它停止在auth本身給出:無法進行身份驗證。
我能夠連接到谷歌的smtp serever,因爲我得到:'mx.google.com'作爲結果:
print $ smtp-> domain,「\ n」;
這是什麼,我做錯了?請幫忙。
我放棄了'你好'的說法,並糾正了報價錯誤,仍然沒有結果。 TLS和SSL模塊可用於perl 5.14窗口。我不能使用它,因爲我必須在Windows中使用win32 :: serialport。請通過調整上述代碼本身來告訴我們。 – CuriousSid
對於提及「如果您仍然無法進行身份驗證」,請+1。「確保您已安裝模塊MIME :: Base64和Authen :: SASL。」 – Anshu