Perl: Net::SMTP mails to myself skip the Inbox

39 Views Asked by At

I am trying to send the Gmail from myself using the Google Account's "Application Password". https://support.google.com/accounts/answer/185833?hl=en

The problem is that when I send the mail using the SAME Google account for user, sender and receiver, then the mail will skip the Inbox. I can find the mail in the Sent box, but I got no notification.

Do anybody know how can I put it in the Inbox and let me have the notification?

The environment is as follows:

  • OS: Windows 10 + WSL + Ubuntu 22.04.4 LTS
  • Language: Perl 5.34.0
    #!/usr/bin/perl -w
    
    use Net::SMTP;
    
    $user = 'my_mail_at_gmail_dot_com';
    $pass = 'application password string';
    $sender = 'my_mail_at_gmail_dot_com';
    $receiver = 'my_mail_at_gmail_dot_com';
    
    $smtp = Net::SMTP->new('smtp.gmail.com',
                           Port => 587,
                           Timeout => 30,
                           Debug => 1,
                           #Debug => 0,
                          );
    
    $smtp->starttls();
    $smtp->auth($user, $pass);
    $smtp->mail($sender);
    $smtp->to($receiver);
    
    $smtp->data();
    while(my $data = <DATA>){
      $smtp->datasend($data);
    }
    $smtp->dataend();
    $smtp->quit;
    
    __DATA__
    Subject: mail testing
    From: NEW_NEWS <my_mail_at_gmail_dot_com>
    mail test
0

There are 0 best solutions below