How to Send Emails with Next JS and Nodemailer

Поділитися
Вставка
  • Опубліковано 11 вер 2024
  • UPDATED 2024 - I no longer recommend using Nodemailer for sending emails. Instead use Resend (resend.com), as they make it very easy to send emails and have a generous free tier.
    In this video you'll learn how to build a contact form in Next JS that sends emails using API routes and Nodemailer. I'll be using a gmail account in this video, but it will work with other email providers as well.
    Starting Files: github.com/nik...
    Finished Files: github.com/nik...
    Github: github.com/nik...
    Support Me: www.buymeacoff...
    Contact Me: nikitadev292@gmail.com
    #nextjs #react #nodemailer

КОМЕНТАРІ • 190

  • @kby9001
    @kby9001 Рік тому +24

    Dude you're such a lifesaver. I was making this way too complicated trying to use the Gmail API and Express and knew there had to be an easier way with using Next. Thank you!

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

      I wanted to ask, in my application I'm wanting to take the users email that they input and send the mail directly to them instead of myself. How would i pass that value from the form into mailOptions?

    • @nikita-dev
      @nikita-dev  Рік тому +2

      you can remove the "to" prop from the mailOptions and just set it in the sendMail() call in the handler. In that case, you would be setting the "to" property on the fly, on every request, with whatever the user passed to you in the body.
      If you take this approach, I would add stronger email validation (using a validation library) to ensure that the user sent a valid email before calling sendMail()

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

      @@nikita-dev I came across your video wanting to learn about nodemailer and I ended up learning alot more, I'm using zod in my handler to validate emails would think this is a good way to validate the email? looking forward for more videos about nextjs, thank you so much

    • @nikita-dev
      @nikita-dev  Рік тому

      No problem! And yes, Zod should be sufficient for email validation

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

      Bro, JUST the same thing I was trying to do. I spent 4 hours and got just frustrated and dropped the idea.

  • @СергейМурин-д6ч
    @СергейМурин-д6ч Рік тому +5

    after 5 hours of trying different options, i finally found the best one

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

    it was fun making this work on next.js 13, lot of new things i learn within 2 hour it take for me to finish it. thanks bro

    • @Sport-word
      @Sport-word Рік тому +1

      Hello keyonlevis. i have been trying to make it work on nextjs 13. However, i have not been able to get it right. Please kindly help me with your code. I will deeply appreciate you. Thanks

  • @zee_designs
    @zee_designs 8 місяців тому

    Hey Nikita, you guided me in the right way, I was struggling with this topic, Thank you

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

    Great tutorial, thanks for posting this. There is a lot of ends and outs to this process and this video helped give a great guide to getting me toward the track I need!

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

    Thank you so much for this. Was bashing my head against a wall trying to figure out how to send an email without using a paid service. What I'm wondering now is how, whoever submitted the form, they get a confirmation email as well.

    • @nikita-dev
      @nikita-dev  Рік тому

      you can call the sendMail method again, but just override the "to" property with the user's email that they input. For example:
      await transporter.sendMail({
      ...mailOptions,
      ...generateEmailContent(data),
      subject: data.subject,
      to: RECIPIENT_EMAIL
      });
      (replace RECIPIENT_EMAIL with the data that was passed from the user)

  • @defdev007
    @defdev007 9 місяців тому

    I've been trying to integrate this feature ever since, but I couldn't find anything that worked for me. Thanks a lot for sharing

  • @Phas0ruk
    @Phas0ruk Рік тому +3

    One issue I had was that my windows firewall was blocking outgoing connections on port 465 which is what gmail uses. When running my app locally, when I temporarily disable the firewall, it works.

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

    Thank you, I ran into issue with Express and whatnot and it just got too complicated. This makes way more sense.
    Great explaination too!

    • @nikita-dev
      @nikita-dev  Рік тому

      thank you, I'm glad it was helpful!

  • @m.efremova4649
    @m.efremova4649 Рік тому +1

    This is exactly what I've been looking for! ❤

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

    Superb content. Clear and slick. Keep it up!

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

    An elegant solution, and well explained. Thanks!

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

    Perfectly explained and definetely a huge help on my learning journey as a developer, Thank You!!

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

    Awesome tutorial!! Well explained and you saved me hours for implementing a email handler!!

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

    Awesome video, my guy. You the man!!!! Keep em coming

  • @Jesus-xp6cf
    @Jesus-xp6cf Рік тому +1

    Thanks for the help!! Amazing tutorial.😁

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

    Great explanation! Straight to the point.

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

    Thank you so much for sharing your experience, Sir.

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

    Thank you, any possibility of a follow up to this video, migrating to the Nextjs 13 App directory? I am having an absolutely impossible time trying to implement the teachings of this video to their new system of API usage. Much, much appreciated.

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

    Hi Onelight! I like your solution since I was trying to get a functionality like this using services like sendgrid but all of these require you to have a private email domain which I can't affort right now.
    But I do have a question, I implemented your solution almost identically to yours with almost the same validations: isn't it kind of a vulnerability that an user can spam the send button or creating a script to completely flood your inbox? If that's the case, what can I do to prevent that from happening?

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

    Wow, Thank you so much!

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

    Why is nodemailer not sending the email when deploying on Vercel?

    • @nikita-dev
      @nikita-dev  Рік тому +1

      it is likely an issue with your environment variables

  • @evanmarshall9498
    @evanmarshall9498 Рік тому +7

    I followed this video verbatim and it works flawlessly. Well, I adapted it a bit to use TailwindCSS for the contact form but still works great... locally. When I push to my production deployment on Vercel and test it live, it does not work. I added the environment variables (EMAIL & EMAIL_PASS) to Vercel settings thinking that was the issue, but still no fix. Can anybody help me with this? Does anybody have similar issues?
    EDIT: Needed to perform a new deployment after adding Envrionment Variables to Vercel in order to update the site with the variables. Ran a test and it works!! Thank you!

    • @pedro.sh101
      @pedro.sh101 Рік тому

      hi Evan, could you explain a little better how you made it work? having the same issue here, but on netlify

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

      @@pedro.sh101 I was only updating locally so in order to update in production I needed to push a new deployment to vercel in order for the environment variable to take place.

    • @gubmx20
      @gubmx20 6 місяців тому

      I had to do the same thing!

  • @user-vw3xq9sj1b
    @user-vw3xq9sj1b 6 місяців тому

    THIS TUTORIAL WAS HELPFUL !!

  • @SergioSanchez-rh4po
    @SergioSanchez-rh4po Рік тому

    Super helpful, thank you very much. Keep up the good work!

  • @RahulSingh-on7ko
    @RahulSingh-on7ko 2 місяці тому

    hi i am facing issue with fetch the contact api . 400 bad request coming
    export const sendContactForm = async (data) =>
    fetch('api/contact', {
    method: "POST",
    body: JSON.stringify(data),
    headers: { "Content-Type": "application/json", Accept: "application/json" },
    }).then((res) => {
    if (!res.ok) throw new Error("Failed to send message");
    return res.json();
    });

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

    Thank you for create amazing clearly tutorial. So helpful for me.

  • @neutrallane
    @neutrallane Рік тому +3

    Its not working on my end... i followed everything

    • @nikita-dev
      @nikita-dev  Рік тому +1

      what part specifically is not working?

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

    everything works perfectly fine, just a question, is this api/contact public for everyone when we host it? Is there a risk of this data being leaked?

  • @noone-dx6tr
    @noone-dx6tr Рік тому +3

    Hey, thanks for the video! Could you also make a tutorial on how to additionally send an attachment via this form and nodemailer?

    • @noone-dx6tr
      @noone-dx6tr Рік тому

      Please let me know what you think, I Have looked up on the internet and could not find much help, there are also not answered questions about it on stack overflow, so this video could help a lot of people

    • @nikita-dev
      @nikita-dev  Рік тому +1

      I will definitely consider it!

    • @noone-dx6tr
      @noone-dx6tr Рік тому +1

      Thank you!

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

      @@nikita-dev :(

  • @bespokeprogramming
    @bespokeprogramming 8 місяців тому

    You are a legend. Thank you!

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

    Dude you're great. This helped me a lot❤❤❤❤

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

    Also thanks for posting repo it annoys me when people dont do so lol

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

    Very helpful. Subbed. Thank you.

  • @c4pancake
    @c4pancake 6 місяців тому

    If using newer versions of Next.js, would you just add "use client" to the top? Or would you do this a different way?

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

    Great!

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

    This was really really helpful thanks

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

    Thanks!

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

    thank you so much bro lots of love . it helped me in my porject. 🥰

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

    I hope I get a reply from this. I can't seem to accomplish it via using Outlook, it sends me error code 535 5.7.139 Authentication unsuccessful. I'm doing a blind approach on this configuration. Please I do need help on this matter.

    • @nikita-dev
      @nikita-dev  Рік тому

      Here is a helpful article on using Nodemailer with Outlook: ourcodeworld.com/articles/read/264/how-to-send-an-email-gmail-outlook-and-zoho-using-nodemailer-in-node-js

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

    thanks!

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

    Thank you so much, your video helped me a lot

  • @CodeInDraw
    @CodeInDraw 8 місяців тому

    Thank you so much. Its really helpful

  • @oghenevwefepeace2501
    @oghenevwefepeace2501 9 місяців тому

    Nice video, It worked perfectly, Thank You

  • @cacodelphia_
    @cacodelphia_ 8 днів тому

    awesome man, thank you

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

    Great tutorial. One question though. I would like to send the automated confirmation email to the client, rather than to myself. How do you adjust the mailOptions function to allow this? Thanks in advance

    • @nikita-dev
      @nikita-dev  Рік тому

      You would have to overwrite the "to" property in the mailOptions object. You will have to do that dynamically on each request. For example:
      await transporter.sendMail({
      ...mailOptions,
      ...generateEmailContent(data),
      subject: data.subject,
      to: RECIPIENT_EMAIL
      });
      (replace RECIPIENT_EMAIL with the data that was passed from the user)

  • @SF-tv2so
    @SF-tv2so 6 місяців тому

    Thank u so much. Ur video has helped me

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

    Get tutorial! But I have an error on my end. It's saying: Cannot read properties of undefined (reading 'sendMail') at handler. How do I fix this?

    • @nikita-dev
      @nikita-dev  Рік тому

      it looks like your transporter object is not being imported correctly. Are you exporting from the config/nodemailer.js file?

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

      @@nikita-dev Thank you, I went back and copied exactly what you had and it finally worked. I must have had a typo somewhere. Thank you for responding!! Also, great tutorial not get! lol

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

      @@nikita-dev Would you be willing to give me advise on transferring this to an existing project. I'm now getting an error stating it cannot resolve 'nodemailer'. The error suggest trying a 'preferRelative' . How would I add this to the config/nodemailer file?

    • @nikita-dev
      @nikita-dev  Рік тому

      did you install the nodemailer package from NPM? (in your other project)

  • @Igor-uz3vn
    @Igor-uz3vn Рік тому +1

    Greate tutorial! How did you solve the problem of sending a message from Vercel hosting?

    • @nikita-dev
      @nikita-dev  Рік тому

      You just have to make sure your environment variables are set up correctly. If you change them at all, make sure to rebuild the environment so it can pull in the updated values

  • @user-to5dz8sc1e
    @user-to5dz8sc1e Рік тому +1

    if I want to change "from" and "to" for differnet mail then this EMAIL_PASS pin is needed for both mail ?? how can i do that?

    • @nikita-dev
      @nikita-dev  Рік тому

      you will only need to change the EMAIL_PASS variable for the sender's email (the "from" email). Yo don't need a password for the "to" email

  • @andersbraathen1256
    @andersbraathen1256 9 місяців тому

    Great video, thanks!

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

    Bravo!

  • @ManuelGuillenSerna
    @ManuelGuillenSerna 4 місяці тому

    Thank you so much for the video, it really helped make my contact form. The only issue that i have is that, even though i have my type="email" on the email input, i can write whatever (without an @) and the email is still sent. It isn't a big problem but i would really appreciate if you could help me with this. Thank you!

  • @yuvalbra
    @yuvalbra 9 місяців тому

    how can i add attachment file? and where i need to put the file if i want to send it ?

  • @user-zi6ci1ly7z
    @user-zi6ci1ly7z 5 місяців тому

    멋진 튜토리얼 입니다.

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

    Thank you! It worked but HOW do you set up where the sender displays their name in the email and not the "Me" Email?

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

    Hey thanks for the video! I’m having some issues moving to production since the send email function is taking more than 10 sec to run which makes that vercel stop the execution due to limitations on the free plan. Do you think it could be a solution for this? Thanks in advance!

    • @nikita-dev
      @nikita-dev  Рік тому

      It shouldn't take more than 10sec to run... Im assuming there's an error in your API route. Are you able to check the server logs and see if there are any errors that are logged?

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

      @@nikita-dev It will be returning a 504 because if its hosted on vercel it could be doing a "cold start", causing the resource to time out?

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

      Did you find a solution to this?

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

      @@AdamBakerMTB not really. I ended up using sendgrid.

  • @sudam-d
    @sudam-d 6 місяців тому

    Appreciate this so much

  • @amitodak
    @amitodak 4 місяці тому

    hi, do you tutorial or other resources that have for file upload in pdf format? thank you

  • @jayeshsingh28
    @jayeshsingh28 7 місяців тому +1

    Chakraui updated docs disabled for button is now isDisabled hope it helps✌🏻🔥

  • @MohammadbasitYousofi-ih5iv
    @MohammadbasitYousofi-ih5iv Рік тому +1

    Hey!
    Error: fs not found from node_modules folder of node mailer
    tell me the sulotion

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

    Thank you so muchhh!!

  • @Sport-word
    @Sport-word Рік тому

    This is not working on nextjs 13. latest version. Please help

  • @mydaily21
    @mydaily21 9 місяців тому

    about template. is possible if import template email.html to api? not copy all code from template. i mean just import it

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

    Thank you so much!

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

    Awesome thanks.

  • @user-nn8ui8rx7j
    @user-nn8ui8rx7j Рік тому

    Could you make a version of this video that does not rely upon chakara?

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

    Thank you for the tutorial! I got everything working until the very end. The contact form works on my localhost but not on my deployment link with Vercel. I keep getting "Failed to send message" using my deployment link. Any idea why?

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

      using the chrome dev tools, there is a network error saying ""Missing credentials for \"PLAIN\""

    • @nikita-dev
      @nikita-dev  Рік тому +3

      It is likely an issue with your environment variables. Can you verify that they are set properly and you’re able to access them from the Vercel app? (Create a test endpoint that returns some of the non-sensitive env variables like the email and ensure that you get back the right value)

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

      @@nikita-dev Thank you so much, that did the trick! I needed to add my env variables to my vercel app.

  • @user-nl2fh8ku4m
    @user-nl2fh8ku4m Рік тому +1

    thanks a lot:)

  • @appstuff6565
    @appstuff6565 3 місяці тому

    Hey Nikita thanks for this. Im using Nextjs and supabase and im now requiring to use a smtp, for sending sign up and reset emails only, so what do you think is the best way to do about this? Nodemailer + Amazon SES? or can I just use nodemailer alone

    • @nikita-dev
      @nikita-dev  3 місяці тому +1

      Honestly I would recommend just using AWS SES or Resend

    • @appstuff6565
      @appstuff6565 3 місяці тому +1

      @@nikita-dev thanks nikita.

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

    I really appreciate it

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

    Just Awesome

  • @user-fg5oz1on4m
    @user-fg5oz1on4m 9 місяців тому

    works local but not working on server "gateway timeout 504"

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

    is the spinning annimation part of Chakra-ui or embedded into nexjs?

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

    Awesome tutorial. Question: how do we supply env variables in production? Thanks in advance for any help!!

    • @nikita-dev
      @nikita-dev  10 місяців тому +1

      It depends on where you deploy (Netlify, Vercel). There is usually a tab in your configuration settings called "Environment Variables". You should be able to find detailed steps by looking through the docs of the cloud company you are using (to deploy).

  • @wolfie8748
    @wolfie8748 Місяць тому

    but this is basically me messaging me ?
    when I check who sent the email it is the user we entered so how can random people mail me for my portfolio website?

    • @nikita-dev
      @nikita-dev  Місяць тому +1

      You’ll have to rely on the email sent in the form field to know who submitted the contact form. Sure the user can pass a fake or invalid email in that field, but if they really want you to get back to them, it will be a valid email.
      If you want the email to come from the user who is actually contacting you, you should use an HTML email link: with href set to: mailto:myemail@gmail.com
      This will open the users default email client and allow them to send an email to you directly.

    • @wolfie8748
      @wolfie8748 Місяць тому +1

      @@nikita-dev thank you very much!

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

    for me, it doesn't work and I don't know why. l receive the message " Failed to send message" also I receive the next Error: Missing credentials for "PLAIN"

    • @nikita-dev
      @nikita-dev  Рік тому

      This is likely an issue with your environment variables. Are you able to get it working locally by hard coding the values into your nodemailer instance?

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

    Thanks for your great explanation, i would like to ask can i adapt this approach in my project for sending email notification within my workplace for workflow tasks such as approval email notifications when a new request has created by employees ? regards

    • @nikita-dev
      @nikita-dev  Рік тому +1

      Yes, you can reuse the same nodemailer client to send emails for various different actions that you want to handle in your app. The only thing that would change is the email content

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

    Error: Connection timeout
    code: 'ETIMEOUT',
    command: 'CONN'
    Please tell me how i can solve this error.

    • @nikita-dev
      @nikita-dev  10 місяців тому

      when are you getting this error?

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

    Good job, but I need help if you can. I want to use this form to send email with attachment or embedded image. Nodemailer has an example for it but that example uses locally stored images which is not what I need. I need user to be able to upload picture and send it to email. Please give me some guidance.

    • @nikita-dev
      @nikita-dev  Рік тому

      You'll have to first store the image somewhere (S3, or whatever cloud provider you're using), then get the public URL to that image and use that to create an image in the email HTML. This logic can all be done in the handler

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

    didn't work for me, Getting this Error Error: Missing credentials for "PLAIN". Please help

    • @nikita-dev
      @nikita-dev  Рік тому

      this is likely due to an environment variables issue (the nodemailer client is not getting the right email/password values). can you verify that your env variables are set up properly?

  • @treyrader
    @treyrader 3 місяці тому

    Is this possible to setup without using 2F auth? If so, do i just ommit the pass variable? Having some issues with getting it to work. Might have to rabbit hole for the night

    • @nikita-dev
      @nikita-dev  3 місяці тому

      honestly I would recommend using Resend instead of Nodemailer

    • @treyrader
      @treyrader 3 місяці тому

      @@nikita-dev isn't resend not free? I'll look into it for sure. thanks man

    • @nikita-dev
      @nikita-dev  3 місяці тому

      they have a pretty generous free tier

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

      @@nikita-dev Don't we need to add domain in order to send emails from any place. Would have to buy domains right?

  • @Lyzeuph
    @Lyzeuph 9 місяців тому

    Thank you!!!!

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

    Great video

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

    Very good

  • @arounaouattara6037
    @arounaouattara6037 4 місяці тому

    Thanks

  • @RaulGlasgow
    @RaulGlasgow 8 місяців тому

    good job!

  • @MdNaimurRahmanHera
    @MdNaimurRahmanHera 6 днів тому

    Awesome

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

    As far as I could tell, gmail does not support media queries

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

    It sends message undefined undefined to my gmail..how do I fix this?

  • @jackpaterson5324
    @jackpaterson5324 3 місяці тому

    it works👍

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

    How can I fixed this? thanks

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

    great

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

    I don't want to let user type email, I want to get their email automatically and then send mail by that email, so user get scared from spamming mail
    bcz I am using this form for my own portfolio website but user may spam mail me as its not his/her mail

    • @MrX-ct8dj
      @MrX-ct8dj 6 місяців тому

      how did you acheive this

    • @sohambhikadiya3346
      @sohambhikadiya3346 6 місяців тому

      @@MrX-ct8dj I added limit so that user can only send 1 mail per hour with the help of local storage.
      When user sends mail, it sets a timestamp to local storage and it checks for this every time before sending mail

  • @DJ_Melech
    @DJ_Melech 4 місяці тому

    anyone having trouble getting their Toast to pop up when an e-mail is sent?

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

    Sir when I deploy this aap to firebase hosting nodemailer does not send an email..please reply

    • @nikita-dev
      @nikita-dev  Рік тому

      This is because firebase hosting only supports static files (not SSR pages or API routes). It's possible to host your entire Next App (or just API routes) through Firebase functions, but it gets pretty complicated. I would recommend sticking with Vercel or Netlify for deploying NextJS apps. More details here: stackoverflow.com/questions/70992583/nextjs-api-routes-not-working-with-firebase-hosting

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

      @@nikita-dev can we host APIs which build in next js like in api folder to vercel?

    • @nikita-dev
      @nikita-dev  Рік тому

      yes, Vercel supports SSR and API routes

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

    Can you use this to send to outlook emails?

    • @nikita-dev
      @nikita-dev  Рік тому

      yup! you can find some examples online: ourcodeworld.com/articles/read/264/how-to-send-an-email-gmail-outlook-and-zoho-using-nodemailer-in-node-js

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

    Everything works great during development, after transferring to amazon amplify it does not work. Who knows how to solve problem?

    • @nikita-dev
      @nikita-dev  Рік тому

      Here is a helpful doc for deploying SSR Next.js apps:
      docs.amplify.aws/guides/hosting/nextjs/q/platform/js/#deploy-and-host-a-hybrid-app-ssg-and-ssr
      Some things to note: when you're setting up the build configuration, set the
      "Distribution Directory Path" to ".next", and then make sure to add these to the amplify.yml file under:
      build:
      commands:
      - env | grep -e EMAIL -e EMAIL_PASS >> .env.production
      - npm run build
      and then make sure to set these environment variables for the Amplify app (found under "Advanced Settings" or on the left side bar "Environment Variables")

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

    Hi, thx a lot !, just not working in production. Mail received with "undefined" instead of req.body value

    • @nikita-dev
      @nikita-dev  Рік тому

      were you able to get it working locally?

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

      @@nikita-dev I'm having the same problem. It works locally but if I deploy to Amplify, it doesn't work. I've tried entering the env variables into Amplify but even then it gives me a 405 error.

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

      @@formorri Same issue here. Could this be gmail blocking the request?

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

    awesome job but, thanks a lot