For this, you'll need to sign into your gmail/google workspace account with password. For security reasons, it's prefered to use app password. And if you use 2FA (which you should), you may get "password incorrect" when using your regular password. Follow these steps to create an app password:
- Go to your Google Account.
- Select Security.
- Under "Signing in to Google," select App Passwords.
- At the bottom, choose Select app and choose "Mail" and for the Select device option, select "Custom" and enter a descriptive name for the app.
- Your password will be shown on screen, it's the 16-character code in the yellow bar.
- Copy it and tap Done.
These instructions may change, you can find them (here)[https://support.google.com/mail/answer/185833#app-passwords] as well
Replace the sender_address
and sender_pass
variables below and use the function where needed!