(perl Net::SMTP) authentication failure using gmail smtp server

≯℡__Kan透↙ 提交于 2019-12-06 09:07:26
use Net::SMTP;
my $smtp = Net::SMTP->new ....

afaik you need to use an encrypted connection to send via gmail, use Net::SMTP::TLS or Net::SMTP::SSL (with port 465)

Hello=>'user@gmail.com'

'Hello' is not an email address, put your hostname there instead

$sender = "user@gmail.com";
...
$receiver = "user@gmail.com";

put these in single quotes

if you still get "could not authenticate." make sure you have the modules MIME::Base64 and Authen::SASL installed.

 $smtp->datasend("To: <$reciever> \n");

should be $receiver, not $reciever

user1092042

Gmail uses TLS/STARTTLS on port 587, SSL on port 465. Please follow Sending email through Google SMTP from Perl. Alternatively you could use Email::Send::SMTP::Gmail. I recommend this as it is way easier to use and has many more features.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!