How to send email using Gmail API (uses OAuth2 and nodemailer)

Поділитися
Вставка
  • Опубліковано 4 лют 2025
  • #gmail #oauth2 #nodemailer
    In this video you will learn how to send #emails from the gmail #api using #nodemailer and #oauth2.
    ⭐ Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite plugin integrates with all the top editors and IDEs to give you smart completions and documentation while you’re typing. I've been using Kite for 6 months and I love it! www.kite.com/g...
    GitHub (Tutorial): github.com/tru...
    FREE $100 credit @Digital Ocean: m.do.co/c/3208...
    Subscribe: www.youtube.co...
    Support the channel:
    Paypal: www.paypal.me/...
    Patreon: / trulymittal
    ---------------
    Other useful Playlists
    ---------------
    #RestAPI (#NodeJS and MongoDB): • REST API using NodeJS ...
    #API Authentication using #JWT: • NodeJS API Authenticat...
    #Firebase: • Firebase | Build a Not...
    Docker: • Docker
    MongoDB: • Learn MongoDB in 50 mi...
    Html/Css/Js: • HTML / CSS / JS
    Android: • Android
    Challenges: • Challenges
    ---------------
    What I use
    ---------------
    Mouse: amzn.to/2O9RJtu
    Keyboard: amzn.to/2qxajCU
    Keyboard 2: amzn.to/2XDWH4X
    Monitor: amzn.to/2pDg7dH
    Processor: amzn.to/347WWIb
    RAM: amzn.to/2QEkUqw
    Graphics: amzn.to/33aBrF4
    Microphone: amzn.to/2DabdI9
    #StayHome #WithMe #yoursTRULY #tutorial #howto #android

КОМЕНТАРІ • 492

  • @mafiacodes
    @mafiacodes  2 роки тому +7

    Refresh tokens may stop working after they are granted, either because:
    The application has a status of 'Testing' and the consent screen is configured for an external user type, causing the token to expire in 7 days
    With reference to Github page: github.com/googleapis/google-api-nodejs-client#readme

    • @cumpaMira
      @cumpaMira 2 роки тому

      I came back for this reason, thank you

    • @ashwinr001
      @ashwinr001 2 роки тому

      @yoursTRULY When i try to publish app, it says Verification not required. but still i'm getting the app not verified warning. What's the procedure to get a token that will not expire?

    • @cumpaMira
      @cumpaMira 2 роки тому +2

      @@ashwinr001 have you solved the problem?

    • @samudramitra4900
      @samudramitra4900 Рік тому +2

      @@cumpaMira .. I think I have solved it,.. to prevent this,.. go to ur oauth consent screen and change the status from testing to in production by pressing on PUBLISH

    • @ayuenmadyt
      @ayuenmadyt Рік тому

      @@samudramitra4900 did google verify your app because production status require verificcation

  • @rakibdev
    @rakibdev 4 роки тому +76

    These type of videos are rare to find on the internet, focuses on real issue.

  • @lorentabio
    @lorentabio 3 роки тому +27

    No wonder why UA-cam is considered the best university nowadays because there are so many great teachers here, and this channel is a good example. The explanation is very clean and easy to understand. What a great video.

  • @rcdunnii
    @rcdunnii 7 місяців тому +2

    Spent many hours trying to navigate the google oauth setups and using ai, all to no avail. This is first explanation that worked! Many thanks!!!

  • @thinhon54
    @thinhon54 2 роки тому +2

    This video is my life savior. I tried numerous methods but only this one works. Thank you so much!!

  • @cisar2218
    @cisar2218 2 роки тому +55

    For anyone who receives 403 at 6:00 has to add gmail account to test users at project's OAuth consent screen.

  • @agehjeremiah
    @agehjeremiah 3 роки тому +7

    You have no idea how helpful this tutorial is for me. Thanks a lot.

  • @ErolAspromatis
    @ErolAspromatis 3 роки тому +4

    I love it when a video like this saves me from jumping off a cliff!

  • @Kwuasimoto
    @Kwuasimoto 3 роки тому +13

    This is an extremely detailed and well thought out video, well done man! Made it super easy to think about how to implement this into my website

  • @sandeepsingh-ts7xb
    @sandeepsingh-ts7xb 11 місяців тому +1

    Kudos for such a great tutorial. Very well explained, every minute detail covered. It worked in one-go.

  • @ThePhysicsTree
    @ThePhysicsTree 3 роки тому +3

    Many many thanks.... Amazingly clear voice.... This coming from a Physics teacher who thinks he is very articulate himself.

  • @bhagabatiprasad2612
    @bhagabatiprasad2612 4 роки тому +19

    I can't tell you that how much this video helped me. Thanks a lot. Keep it up!

  • @JOEREIS1983
    @JOEREIS1983 2 роки тому +1

    hey man. Tks for this. It's save me in my work.
    We used a web system with google cloud function send mail for clients, but, because new polices of google, are necessary Oauth, and break send mails in my site.
    Thanks for shared your knowledge.
    Persons equal you, make a better world.
    sorry for my english.

  • @soaring_dove
    @soaring_dove 4 роки тому +8

    ;) dude, tell people to use environment variables in your tutorials, some people code without really thinking about it, thanks for the video

    • @mohammadyeasinalfahad5468
      @mohammadyeasinalfahad5468 4 роки тому +1

      Yeah I agree too

    • @mafiacodes
      @mafiacodes  4 роки тому +2

      Well yes, in my nodejs auth jwt series, I made that production ready, so we hv used env variables

  • @MarshallsDocs
    @MarshallsDocs 3 роки тому +5

    Thank you friend you saved me hours and even days of googling and frustration 👍 great job

  • @danvictor4341
    @danvictor4341 3 роки тому +3

    Thanks, man, this was well explained. You redefined "Do it yourself"

  • @christianleypoldt8385
    @christianleypoldt8385 3 роки тому +2

    Thanks man! Have struggled with this for hours.

  • @bhavikpunmiya9641
    @bhavikpunmiya9641 2 місяці тому +1

    Thank you so much ! , you made it so easy for me ! Earned a new Subscriber

  • @hungvochanh7934
    @hungvochanh7934 3 роки тому +3

    Thanks you very much, you save my day :D I forget to add client id and client secret before generate refresh token. Every documents absolute do not mention this step, so againt thanks you

  • @almedinshala8794
    @almedinshala8794 10 місяців тому +1

    good tutorial, helpful in 2024 for a small project

  • @techsamar
    @techsamar 4 роки тому +34

    Those who are getting authorization error, add your email address in test users section then it will work as it should.

    • @ranoveria
      @ranoveria 4 роки тому +5

      You saved my ass few hours of time :) Thank youuu

    • @LifeWithRilla
      @LifeWithRilla 4 роки тому +2

      You good sir are a saint! Thank you!

    • @KHANSOFFICIAL
      @KHANSOFFICIAL 4 роки тому +2

      Thank you❤️

    • @kavindapathirana9562
      @kavindapathirana9562 4 роки тому +1

      where is that section?

    • @mafiacodes
      @mafiacodes  4 роки тому +5

      Oauth consent section -> add test user
      Inside google developer console

  • @modern_sapien
    @modern_sapien 3 роки тому +1

    Worked like a charm! This is a great video on forwarding emails using Nodemailer through a gmail account! You covered everything

    • @mafiacodes
      @mafiacodes  3 роки тому +1

      Thanks bro 😎

    • @mafiacodes
      @mafiacodes  3 роки тому

      Thanks again for your support 😊

    • @modern_sapien
      @modern_sapien 3 роки тому +1

      @@mafiacodes you literally saved me hours! Thank you!

  • @Agamista379
    @Agamista379 4 роки тому +6

    thanks a lot for the detailed step by step tutorial, this has helped a lot

  • @gasinefirst6624
    @gasinefirst6624 Рік тому +2

    Great content man.Your videos are well detailed and easy to understand👏👏👏

  • @razaqonweb
    @razaqonweb 2 роки тому +2

    This video was super helpful. Everything worked as expected. Thank you very much.

  • @graceadjei2099
    @graceadjei2099 4 роки тому +2

    Best video everrrr!!! It worked like a charm! Thanks very, very much bro.

  • @zellonews
    @zellonews 4 роки тому +1

    Awsome, congratulations, I was having problems to send email using nodemail, but this tutorial solved my problem, VERY USEFULL -THANKS ;-)

  • @54.soumyanetrapal5
    @54.soumyanetrapal5 3 роки тому +1

    Wonderful work... very handy way to send custom mails..

  • @mcTraher1
    @mcTraher1 2 роки тому +2

    Hey man thank you for ure job, very clear and helpful!

  • @usama_javed
    @usama_javed 2 роки тому +2

    Very helpful, great job bro ❤❤❤

  • @rizwanmustafa0000
    @rizwanmustafa0000 2 роки тому +1

    Thank you so much for helping me out.

  • @Biometrics
    @Biometrics 2 роки тому

    Thanks a fortune! I am finally out of the woods. This helped me a great deal.

  • @tomchambers9787
    @tomchambers9787 3 роки тому +1

    Fantastic job.. voice is so clear.... do Paterons get access to the code you use on your youtubes? That would add even more value... Thank you for sharing you knowledge.

    • @mafiacodes
      @mafiacodes  3 роки тому +1

      Thank you, my code is all public on GitHub, if someone really likes and wants to support - anyone (even you 😅) can support me on PayPal or patreon.

  • @navtejsingh2731
    @navtejsingh2731 2 місяці тому

    Great presentation. 👏🏻

  • @leonardocoronel8108
    @leonardocoronel8108 4 роки тому +3

    Thx a lot, great tutorial it works perfectly ! ♥ greetings from Argentina !

  • @PazzoFredus
    @PazzoFredus 3 роки тому +77

    Error 403: access_denied The developer hasn't given you access to this app fix:
    Solution:
    1. Go to your developer console.
    2. Go to OAuth consent screen.
    3. Go to +Add users, under test users.
    4. Add the users for the test (even the owner email address if not working without it)

    • @ayushiparmar9745
      @ayushiparmar9745 3 роки тому

      I am facing same error with my login. What to. Please let me know???????

    • @juhandvan
      @juhandvan 3 роки тому +2

      I ran into the same problem. Thank you so much

    • @rajeshamara
      @rajeshamara 3 роки тому +1

      Thanks for the tip. Really help through this error

    • @MAziz-xd6cp
      @MAziz-xd6cp 3 роки тому

      Thanks a lot. Really help through this error.

    • @craigjohnson8279
      @craigjohnson8279 3 роки тому

      @Pazzo_Fredus. Thanks for the info, that helped me a lot! :)

  • @myWayIn619
    @myWayIn619 11 місяців тому

    Your video helped me alot! could you make one for interacting with google sheets?

  • @drewmcdonald4082
    @drewmcdonald4082 4 роки тому +3

    This is awesome! Thank you for making this!

  • @prathamrajdev3242
    @prathamrajdev3242 Рік тому

    Very helpful video. Thank you so much for helping

  • @devsuthar6795
    @devsuthar6795 10 місяців тому

    thank you so much bro very easy to understand and works well

  • @shatanandpatil858
    @shatanandpatil858 2 роки тому

    Worked! Thank you very much! keep posting.. how did you add those smileys in vscode?

  • @yerson557
    @yerson557 3 роки тому +1

    Thanks, man! it worked very well, you made a really good job!

  • @abdulrafeyrizwan2981
    @abdulrafeyrizwan2981 3 роки тому +1

    Man.. this tutorial helped me alot.

  • @prateekchouhan1541
    @prateekchouhan1541 3 роки тому +1

    Thanks for tutorial. Which theme did you use?

  • @itsmeahmedlukman
    @itsmeahmedlukman 2 роки тому +10

    Who is here after google removed the less secure option on March 30th 2022?

  • @rafaelcamaraa
    @rafaelcamaraa 4 місяці тому +1

    If the app is in production mode, will the refresh token stop working, or will it work indefinitely?

  • @hashikamaduranga6122
    @hashikamaduranga6122 3 роки тому

    Awesome explanation and good replier for any kind of issue related to the video

  • @SureshS-md5su
    @SureshS-md5su Рік тому

    Thanks a bunch for the detailed video

  • @wagesapta000
    @wagesapta000 Рік тому +1

    can the from email be replaced with client email and to is our email, so it's not us who sends but the money client sends to us?

  • @mitri-dvp
    @mitri-dvp 4 роки тому +1

    Awesome tutorial man, I appreciate videos like this that show exaclty what to do!
    I do have a question, is there a limit to send emails in this way?

    • @mafiacodes
      @mafiacodes  4 роки тому +1

      I don't know if there are any but u can use it like as if ur using gmail on the app, if u want to send marketing or transactional emails then I recommend using a mail service, have a look at this video: ua-cam.com/video/qFDgH6dHRA4/v-deo.html

    • @mitri-dvp
      @mitri-dvp 4 роки тому

      @@mafiacodes Sweet, thanks again for your help

    • @mafiacodes
      @mafiacodes  4 роки тому

      Subscribe like share

  • @yogeshsharma-wl1xj
    @yogeshsharma-wl1xj 3 роки тому

    Awesome video with all needed steps. Thanks a lot , keep it up !!

  • @gines427
    @gines427 3 роки тому +1

    thanks dude, you are a genius. You helped me a lot

  • @deepaksarvepalli2344
    @deepaksarvepalli2344 3 роки тому +1

    Sir it's working fine for somedays,later it is not working......is there only to publish...or any other...! Thanks for great lecture sir..🙏🙏🙏

    • @mafiacodes
      @mafiacodes  3 роки тому

      Watch as explained in this video for token expiration: ua-cam.com/video/c2b2yUNWFzI/v-deo.html
      Subscribe Like Share

  • @tamngo2862
    @tamngo2862 3 роки тому +1

    Thank you so much. I did with no error

  • @princebhattacharya3216
    @princebhattacharya3216 4 роки тому +1

    Thanks for making this video love from developers India

  • @rohanharnale1888
    @rohanharnale1888 3 роки тому +1

    Awesome tutorial. Thanks..

  • @dishachhabra114
    @dishachhabra114 5 місяців тому

    very clear explaination

  • @fengming8528
    @fengming8528 3 роки тому +1

    Great tutorial! Thanks for the video.

  • @streetcloud3941
    @streetcloud3941 3 роки тому +1

    Very nice video, thanks much friend :)

  • @st3114rr
    @st3114rr 3 роки тому +1

    Thanks so much for the great tutorial!

  • @Shubham_Patil__
    @Shubham_Patil__ 2 роки тому +1

    Do I need to generate access token & refresh toked every time manually when it gets expired?

  • @jakeairbender8941
    @jakeairbender8941 3 роки тому +1

    Thank you so much! This was exactly what I needed.

    • @mafiacodes
      @mafiacodes  3 роки тому

      Subscribe like share

    • @Clepsydris
      @Clepsydris 2 роки тому +1

      Why do we need this, can you tell the application of it.

  • @Bewise_person
    @Bewise_person 2 роки тому

    ITS REALLY WORKED LOL THANK YOU DUDE

  • @pioSko
    @pioSko 2 роки тому

    It works! Amazing! Thank you! Awesome tutorial!

  • @ismiimen5313
    @ismiimen5313 3 роки тому

    Thank youuuuu so much .. it helps me a lot 🌸🌸😍

  • @_dvyne
    @_dvyne 2 роки тому

    Hi, thanks for this tutorial, but this seems not to work in production environment, please do you have any idea how to work around it

  • @jacoboarcemendizabal7036
    @jacoboarcemendizabal7036 3 роки тому

    Thank you very much, a query please, how would it be done in the case of a corporate email (with your own domain) to send emails with nodemailer with google workspace?

  • @daman823
    @daman823 2 роки тому +1

    This works perfectly! Thanks......

  • @ludmilaschlegelova2333
    @ludmilaschlegelova2333 3 роки тому +1

    Thank you very much, it was trully explained very well :)

  • @rivaldoribamar232
    @rivaldoribamar232 3 роки тому +1

    Congratulations! Very cool....

  • @taraskropyvka9044
    @taraskropyvka9044 3 роки тому +1

    Thank you! Saved my time!

  • @deepakmehrotra3426
    @deepakmehrotra3426 3 роки тому +2

    much needed thanks a lot bro!

  • @worldmusics8096
    @worldmusics8096 3 роки тому +1

    Awesome thank you bro

  • @motivateurself9852
    @motivateurself9852 2 роки тому

    Thank You so much. It helped me a lot

  • @anushka10saxena
    @anushka10saxena 3 роки тому

    Thank you so much. It worked in one go!!!

  • @ameetjayawant4114
    @ameetjayawant4114 4 дні тому

    Funnily enough Co-Pilot created this exact same code (literally the exact code) when I used it in VS Code!! Co-incidence?
    One more note for anyone encountering TLS/SSL issues when running this app using node. In windows, in the terminal you will need to disable cert checking by typing in the following:
    SET NODE_TLS_REJECT_UNAUTHORIZED=0

  • @sonny5497
    @sonny5497 11 місяців тому

    thank you this was perfect 💯

  • @ilTHfeaa
    @ilTHfeaa Рік тому

    this helped so much omg thabk tou so much!!

  • @libamlakbirhanu2844
    @libamlakbirhanu2844 3 роки тому

    thank you man, this was really helpful

  • @ahmedrahali8019
    @ahmedrahali8019 3 роки тому +3

    The problem is the token expire after some time and i need to repeat the process again to have nez token

  • @trulymittal
    @trulymittal 3 роки тому +9

    Refresh tokens may stop working after they are granted, either because:
    The application has a status of 'Testing' and the consent screen is configured for an external user type, causing the token to expire in 7 days

    • @devplus7131
      @devplus7131 3 роки тому

      how to solve this issue ????

    • @mafiacodes
      @mafiacodes  3 роки тому

      Publish ur application for verification

    • @danielstill5625
      @danielstill5625 3 роки тому +1

      ​@@mafiacodes Will publishing the app for verification make it stop working for now?? I have it being used for a client's website. Thanks for the video btw.

    • @54.soumyanetrapal5
      @54.soumyanetrapal5 3 роки тому

      @@mafiacodes How to do this?

    • @deepaksarvepalli2344
      @deepaksarvepalli2344 3 роки тому

      @@mafiacodes sir how much time it will take to authorise?

  • @РусланЮсуфов-ф3ш
    @РусланЮсуфов-ф3ш 3 роки тому +1

    Thanks a lot, man! You helped me a lot!

  • @chrismukasa198
    @chrismukasa198 3 роки тому +1

    Thank you so much, you save me 👏🏼👏🏼👏🏼👏🏼👏🏼👏🏼👏🏼👏🏼👏🏼👏🏼

  • @marcosoldatilopez8196
    @marcosoldatilopez8196 Рік тому +1

    excelent video

  • @valikonen
    @valikonen 3 роки тому

    Thank you so much for your clean explication.

  • @shadmanfatin777
    @shadmanfatin777 3 роки тому +1

    OMG why is this so complicated :( However this video is best!

    • @mafiacodes
      @mafiacodes  2 роки тому

      😃 it is not, once you understand the OAuth part, its more explained in detail in this video ua-cam.com/video/c2b2yUNWFzI/v-deo.html

  • @danielli3288
    @danielli3288 3 роки тому +2

    should the client id, client secret and refresh token be env variables?

  • @drB762
    @drB762 3 роки тому +1

    This was excellent. Great job. Thank you.

  • @bhanuprataprathore9836
    @bhanuprataprathore9836 2 роки тому +1

    nice video thanks bro !!1

  • @geetanshrathore4203
    @geetanshrathore4203 3 роки тому

    awesome work keep up with the hard work thanks for the video it helped a lot

  • @phathutshedzomamedzi9820
    @phathutshedzomamedzi9820 3 роки тому +1

    Great tutorial bro

  • @luvdipsinghdadiyala5683
    @luvdipsinghdadiyala5683 2 роки тому

    Thanks It Worked !!! Subscribed

  • @areebkhosa7415
    @areebkhosa7415 3 роки тому +1

    Nice Bhai thanks alot

  • @ruqiaimran2299
    @ruqiaimran2299 3 роки тому

    Your video really help me alot

  • @zydricc2647
    @zydricc2647 4 роки тому +1

    Awesome, I was looking for this

  • @nishalk781
    @nishalk781 3 роки тому +1

    Thanks, this helped a lot

  • @wingcheungkwok8428
    @wingcheungkwok8428 3 роки тому

    Great video! Just curious about that will the gmail access token be expired?

    • @mafiacodes
      @mafiacodes  3 роки тому

      You can get that back from refresh token

  • @HarshSingh-hk8fe
    @HarshSingh-hk8fe 3 роки тому +1

    That was an awesome tutorial
    Can i use this method in production webapp

    • @HarshSingh-hk8fe
      @HarshSingh-hk8fe 3 роки тому

      @@ericamelodecarvalho5714 hi mate i also need emails template for marketing so now im using sendgrid by twilio

  • @angelabeatrizjavier5454
    @angelabeatrizjavier5454 3 роки тому

    So much help! Thank you for this :>

  • @dvalley56
    @dvalley56 3 роки тому +1

    Thanks bro, made my day