Why do I get “SMTP Failed to connect to mail server:” when I try to send an email to a Gmail account using MIME::Lite?

前端 未结 4 1536
隐瞒了意图╮
隐瞒了意图╮ 2020-12-19 18:30

I have following code to send an email in Perl:

#!/usr/bin/perl

use MIME::Lite;

$to = \'toid@domain.com\';
$cc = \'ccid@domain.com\';
$from = \'fromid@doma         


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-19 18:55

    The above worked when

    1. I used my Gmail as the SMTP --> Bet you didn't think you could do that.
    my $smtpserver  = 'smtp.gmail.com.';
    my $smtpport     = 587;
    my $smtpuser     = 'YourGmailHere@gmail.com';
    my $smtppassword = 'password'; ## Plug in your password here
    
    1. Then you have to actually set your security for your Gmail account to a less secure … basically set "Less secure app access" to "ON" setting --> https://myaccount.google.com/security

    Hope this helps others.

提交回复
热议问题