gmail の smtp サーバーを使用してメールを送信するための perl スクリプトを作成しました: smtp.gmail.com -
use Net::SMTP;
my $smtp = Net::SMTP->new('smtp.gmail.com',
Port=> 587,
Timeout => 20,
Hello=>'user@gmail.com'
);
print $smtp->domain,"\n";
$sender = "user@gmail.com";
$password = "mypassword";
$smtp->auth ( $sender, $password ) or die "could not authenticate\n";
$receiver = "user@gmail.com";
$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";
「user」には Gmail のユーザー名があり、「mypassword」にはパスワードがあります。しかし、このコードを実行すると、認証自体で停止し、認証できませんでした。
'mx.google.com' as the result of :
print $smtp->domain,"\n";を取得すると、Google の smtp サーバーに接続できます。
私が間違っているのは何ですか?助けてください。