sorry for the outdated information
Google offers app passwords because of 2-Step-Verification instead of Less secure app access now you can check the following
https://support.google.com/accounts/answer/185833
and Send-MailMessage is obsolete but the other alternatives are not one line by default
maybe you can use the following
# Install the MailKit module if it is not already installed
Install-Module MailKit -Scope CurrentUser
# Import the MailKit module
Import-Module MailKit
# Define email properties
$From = "******@gmail.com"
$To = "******@gmail.com"
$Subject = "Test email"
$Body = "This is a test email sent from PowerShell."
# Create a new SMTP client
$SMTPClient = New-Object MailKit.Net.Smtp.SmtpClient
# Connect to the Gmail SMTP server
$SMTPClient.Connect("smtp.gmail.com", 587, [MailKit.Security.SecureSocketOptions]::StartTls)
# Authenticate with the Gmail SMTP server using the App Password
$SMTPClient.Authenticate("******@gmail.com", "<App Password>")
# Create a new email message
$EmailMessage = New-Object MailKit.Mime.Message
$EmailMessage.From.Add([MailKit.InternetAddress]::Parse($From))
$EmailMessage.To.Add([MailKit.InternetAddress]::Parse($To))
$EmailMessage.Subject = $Subject
$EmailMessage.Body = New-Object MailKit.Mime.TextPart("plain")
$EmailMessage.Body.Text = $Body
# Send the email message
$SMTPClient.Send($EmailMessage)
# Disconnect from the Gmail SMTP server
$SMTPClient.Disconnect($true)