Send email using gmail smtp server
Since Google stopped supporting third-party software which ask you to sign in to your Google Account using only your username and password (on May 30 2022) none of my programs that send email notifications work anymore. Is there a way to make my programs more secure to comply with Gmail's new requirements?
I am simply using System.Net.Mail
VB.NET 2010
Thanks,
Jim
Code:
Sub SendeMail(ByVal MailMSG As String)
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
SmtpServer.EnableSsl = True
SmtpServer.Credentials = New Net.NetworkCredential(MailFrom, MailPassword)
SmtpServer.Port = MailPort
SmtpServer.Host = MailServer
mail = New MailMessage()
mail.From = New MailAddress(MailFrom)
mail.To.Add(MailTo)
mail.Subject = "NEW IP"
mail.Body = MailMSG
SmtpServer.Send(mail)
End Sub
Re: Send email using gmail smtp server
Quote:
Originally Posted by
JimAvanti
Since Google stopped supporting third-party software which ask you to sign in to your Google Account using only your username and password (on May 30 2022)
Not really, Google stopped you from using your user/pass directly, but gives you the ability to use the so-called App Passwords
Go to Google account > Security > Signing in to Google > App passwords
Select your app (in your case select Other custom name) and Generate a password.
This password is the one that you should use in your code (Not your real account password)
Hope that helps
1 Attachment(s)
Re: Send email using gmail smtp server
Thanks for the quick reply cPubis. I must be missing something. My google account doesn't seem to have an App password option. I do have two Apps that are using my Google account though (Amazon Alexa and my cell phone).
Attachment 185690
Quote:
Originally Posted by
cPubis
Not really, Google stopped you from using your user/pass directly, but gives you the ability to use the so-called App Passwords
Go to Google account > Security > Signing in to Google > App passwords
Select your app (in your case select Other custom name) and Generate a password.
This password is the one that you should use in your code (Not your real account password)
Hope that helps
Re: Send email using gmail smtp server
Quote:
Originally Posted by
JimAvanti
Thanks for the quick reply cPubis. I must be missing something. My google account doesn't seem to have an App password option. I do have two Apps that are using my Google account though (Amazon Alexa and my cell phone).
Attachment 185690
App Passwords can only be used with accounts that have 2-Step Verification turned on.
As I can see from the image you posted, you have 2-Step Verification turned off!
Re: Send email using gmail smtp server
Ah! I was hoping not to have to turn 2-step verification on. I suppose I am looking for a way to send an e-mail notification in a more secure way (Like the Alexa and Samsung does) that will satisfy Google's security, or if anyone can suggest a free SMTP server that I could use instead of Google or Yahoo. If not, then I guess I have no other choice but to turn on 2-Step verification.
Thanks,
Jim
Quote:
Originally Posted by
cPubis
App Passwords can only be used with accounts that have 2-Step Verification turned on.
As I can see from the image you posted, you have 2-Step Verification turned off!
Re: Send email using gmail smtp server
You should be using 2-step verification everywhere you can anyway.