[Java] How to send verification email in JSP and Servlet

Поделиться
HTML-код
  • Опубликовано: 28 сен 2024
  • I am showing how to send email using java email API, JSP and Servlet. Using Gmail or any mail SMTP server you can send email in java jsp and servlet. The send email in java using smtp example showed in Netbeans IDE, you can also user eclipse IDE. You can send opt or any type of multimedia message using jsp, servlet, and java mail API.
    ========================
    ***Source code: bit.ly/3ivOl9G
    ========================
    ***TurnON Less Secure App in Gmail: bit.ly/3dpwTRi
    ***Java Mail API jar file Download: bit.ly/3eD3rr9
    ***Java Activation Jar Download: bit.ly/2XoN0co
    ***Hire me on Fiverr
    ====================
    bit.ly/321sxLt
    ***Responsive Login Page and Navbar Design using HTML, CSS: • Responsive Login Page ...
    ***Registration using jsp servlet and mysql: • [Part-1] Login and Reg...
    ***Login and Logout Using JSP and Servlet: • [Part-2] Login and Log...
    ***Subscribe Our Channel: / techtutorialcn
    ***Like Our Facebook Page: / techtutorialcn
    ***Follow us on Twitter: / techtipser
    ***Follow us on Pinterest: / techtutorialcn
    #jsp
    #servlet
    #java
    #email
    *****The Question is going to solve in this video: *******
    send email using java eclipse,
    send email using java netbeans,
    how to send mail using java in netbeans,
    send email using jsp,
    send otp to email in java,
    gmail api java,
    how to send mail in java using servlet,
    javamail api eclipse,
    how to send email using servlet and jsp,
    how to send email in java,
    how to send email in java servlet,
    how to send email in java eclipse,
    how to send email in java netbeans,
    how to send email in java using gmail,
    how to send email in java using smtp,
    send email in java using smtp example,
    send email in java netbeans,
    send email in java eclipse,
    send email in java using gmail,
    send email in java using outlook,
    send email in java web application,
    send email in java 8,
    send email in java,
    how to send email in java using gmail,
    how to send email in java without smtp server,
    how to send a mail using java code in eclipse,
    java code to send email with attachment,
    java program to send email using smtp to multiple recipients,
    java mail,
    java program to send email using outlook,
    java mail jar,

Комментарии • 140

  • @bouchraelfath9749
    @bouchraelfath9749 3 года назад +1

    i follow your steps but when i run the project i got this message"Failed to send verification email " and i don't receive any email.Could you please help me with this

    • @TechTutorialCN
      @TechTutorialCN  3 года назад +1

      If you use gmail it’s your smtp connection issue.

    • @nishusingh5419
      @nishusingh5419 3 года назад

      @@TechTutorialCN same problem i am also getting "Failed to send verification email" please help me

  • @guillermopalaciosgaray
    @guillermopalaciosgaray 3 года назад

    Thanks again for other amazing video! You have been helping me a lot, greetings from mexico

  • @seeker_of_love.....3516
    @seeker_of_love.....3516 5 месяцев назад

    Thansk for the explain the but i got a error, "Error instantiating servlet class [sendemail.Userverify]" the discription is "The server encountered an unexpected condition that prevented it from fulfilling the request." can any one tell how to resolve this error? can u tell me sir?

  • @thanaseelanmaran1019
    @thanaseelanmaran1019 4 года назад

    Thank You so much !!!, Great Video and Explanations

  • @NguyenPhuong-bm9ji
    @NguyenPhuong-bm9ji 2 года назад

    This help me a lot. Thank you so much!

  • @slatepencil-myshoppingcart9907
    @slatepencil-myshoppingcart9907 4 года назад

    Dear Sir Thank you for this wonderful tutorial. I have one request, can you please make one video for below program - How to send mail to particular user based upon document expiry date using Java JSP Servlet. For Example I have written small code to upload file into Mysql database. File can be doc, excel, pdf and so on. While uploading document i have given Validity From Date and Validity End Date. Before expiration of document, mail should sent to user like your this this document is going to expire in suppose 5 days. So how to implement this

  • @gobilladraksharani7634
    @gobilladraksharani7634 3 года назад +1

    Did exactly everything you've shown in the video... But when I click on Register I'm not getting any output why is that?

    • @TechTutorialCN
      @TechTutorialCN  3 года назад

      if you use gmail for security reason you won't get email

  • @taregbalola
    @taregbalola 3 года назад

    Fail to send verification code
    Every thing I review exactly same ur explain
    Also less secure app
    I was changed it

  • @sparshgupta3922
    @sparshgupta3922 3 года назад +3

    For those who are getting this error '535 Authentication credentials invalid'
    write: pr.setProperty("mail.smtp.host", "smtp.gmail.com");
    instead of : pr.setProperty("mail.smtp.host", "smtp.mail.com");
    if you're using a google account for sending the code.
    It will work!

  • @SansaniKhabarlive
    @SansaniKhabarlive 3 года назад +1

    I have one question, Why you did not map servlet in Web.xml file Please Reply

    • @TechTutorialCN
      @TechTutorialCN  3 года назад +1

      It’s do automatically or if you use annotations you don’t need to do configure web.xml file

    • @SansaniKhabarlive
      @SansaniKhabarlive 3 года назад +1

      @@TechTutorialCN Thank You, Actually, I use eclipse and in eclipse, we have to map every single servlet to the web.xml manually. that's why I asked

    • @SansaniKhabarlive
      @SansaniKhabarlive 3 года назад

      @@TechTutorialCN Hello Can you please upload a video about How to set Cookie on the client-side so that they do not need to login all-time
      like Remember me Using JSP and SERVLET

    • @TechTutorialCN
      @TechTutorialCN  3 года назад

      @@SansaniKhabarlive hmm you can do it in two ways using cookies or local storage. I will try to upload it in my free time.

    • @SansaniKhabarlive
      @SansaniKhabarlive 3 года назад

      @@TechTutorialCN if I pay you then can you please teach me JSP, servlet, JDBC
      advance level or if you run any course then please Share the link , I am interested to buy

  • @w2w258
    @w2w258 Год назад

    when i click send, i am still on the white page UserVerify, gmail is not sent, not change to verify.jsp, I have enabled security, please help me

    • @TechTutorialCN
      @TechTutorialCN  Год назад +1

      Instead of using direct password please use app password from google.

    • @w2w258
      @w2w258 Год назад

      @@TechTutorialCN i try but i don't work. in my project, if i import jakarta project run html but don't send email but if i import javax follow your code, project when run have issue:
      Type Rapport d'exception
      message Class [controller.UserVerify] is not a Servlet
      description Le serveur a rencontré une erreur interne qui l'a empêché de satisfaire la requête.
      exception
      jakarta.servlet.ServletException: Class [controller.UserVerify] is not a Servlet
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
      org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:356)
      org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
      org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
      org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:867)
      org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1762)
      org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
      org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
      org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
      org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      java.lang.Thread.run(Unknown Source)
      Please help me, thank you!

    • @w2w258
      @w2w258 Год назад

      i want use jakarta than javax, because i want integrated send email to my other project

  • @ForeverAnsioso
    @ForeverAnsioso 3 года назад

    I have one more question jaja, sorry, Why do I need to use a new Authenticator in 19:39 ?, I have set it null and it works fine. I think that authentication is used to avoid a kind of authorization, idk

    • @TechTutorialCN
      @TechTutorialCN  3 года назад

      Yes it should work. Actually it’s return session which is helpful for debugging.

  • @phuchuynguyenhoang5464
    @phuchuynguyenhoang5464 2 года назад

    U save my life, thanks

  • @nesaramn
    @nesaramn 2 года назад

    Sir when I use getCode() its showing it is undefined for the type User. Please help

    • @TechTutorialCN
      @TechTutorialCN  2 года назад

      Please check out the user class getters and setters method. Also double-check you set the code value properly.

  • @dattakhade8640
    @dattakhade8640 3 года назад

    OTP stored in database but not send to gmai......and shows also null pointer exception

    • @TechTutorialCN
      @TechTutorialCN  3 года назад

      Gmail has security issue to get smtp access from outside.

    • @dattakhade8640
      @dattakhade8640 3 года назад

      @@TechTutorialCN so sir what we do for that....

    • @TechTutorialCN
      @TechTutorialCN  3 года назад

      You can try other email services. Or from a free host service take a free webmail to use it your test project.

  • @gobilladraksharani7634
    @gobilladraksharani7634 3 года назад

    SEVERE: Servlet.service() for servlet [project.Login] in context with path [/SSP_Project] threw exception [Servlet execution threw an exception] with root cause
    /
    java.lang.ClassNotFoundException: javax.mail.Authenticator can you plz help me out to resolve the issue ?

    • @TechTutorialCN
      @TechTutorialCN  3 года назад

      Maybe you are trying with Gmail, and for security reasons it’s happening.

    • @gobilladraksharani7634
      @gobilladraksharani7634 3 года назад

      @@TechTutorialCN can't I use the code for gmail... Will I have to make changes to use gmail?

    • @TechTutorialCN
      @TechTutorialCN  3 года назад

      Yes,the smpt credential

    • @gobilladraksharani7634
      @gobilladraksharani7634 3 года назад

      @@TechTutorialCN ypu have explained about in the video.So I've already changed that in my code.

  • @eeewwwee
    @eeewwwee Год назад

    Hi sir,
    Do you know what issue is this?
    type Exception report
    messageInternal Server Error
    descriptionThe server encountered an internal error that prevented it from fulfilling this request.
    exception
    java.lang.SecurityException: Access to default session denied
    i had tried a lot of solution but it doesn't worked. (Email address and password is correct, and jar is import, and im using app password)

    • @TechTutorialCN
      @TechTutorialCN  Год назад

      Hi, Could you pealse check out this solution: stackoverflow.com/questions/11566772/java-mail-api-exception-thrown-saying-java-lang-securityexception-access-to-d

    • @eeewwwee
      @eeewwwee Год назад

      @@TechTutorialCN It becomes another error
      java.lang.NoClassDefFoundError: Could not initialize class sun.security.ssl.SSLExtension

    • @eeewwwee
      @eeewwwee Год назад

      It solved. Thank you

    • @shobhaborate1980
      @shobhaborate1980 Год назад

      ​@@eeewwweehow do you solve this problems

    • @eeewwwee
      @eeewwwee Год назад

      @@shobhaborate1980 I forgot sorry lol

  • @vignesh5921
    @vignesh5921 3 года назад

    Thanks a lot

  • @minhnguyen0612
    @minhnguyen0612 3 года назад

    amazing video thank you so much!
    but i got this error : javax.mail.AuthenticationFailedException: 535 Authentication credentials invalid
    i'm sure that my username and password were correct (Less Secure App is ON )
    i even tried to use other email services

  • @relaxingvideo8215
    @relaxingvideo8215 3 года назад

    Good! But it send 2 verification code in the same time, can u help fix it!

    • @TechTutorialCN
      @TechTutorialCN  3 года назад +1

      I think you used the code two times in your message area.

  • @09buiphithong90
    @09buiphithong90 4 месяца назад

    please give me file
    activation-jaf1.1.1.jar

    • @TechTutorialCN
      @TechTutorialCN  3 месяца назад

      You may search I google can found in maven repo also

  • @mergilbelindaangelcastillo3183

    me puedes ayudar por favor

  • @deepakkumars8139
    @deepakkumars8139 3 года назад

    I get SMTP not run error what should I do 😑

    • @TechTutorialCN
      @TechTutorialCN  3 года назад

      whats error you are getting?

    • @deepakkumars8139
      @deepakkumars8139 3 года назад

      @@TechTutorialCN javax.mail.MessagingException: Can't send command to SMTP host;
      nested exception is:
      javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)

    • @TechTutorialCN
      @TechTutorialCN  3 года назад

      @@deepakkumars8139 are you using oracle openjdk on linux?

    • @deepakkumars8139
      @deepakkumars8139 3 года назад

      No I'm using eclipse and MySQL for database

    • @TechTutorialCN
      @TechTutorialCN  3 года назад

      I mean which operating system u are using and java version?

  • @thaoo9956
    @thaoo9956 4 месяца назад

    Thank you very much, it helped my project more perfect!

  • @naveenjuttu4596
    @naveenjuttu4596 3 года назад

    Very nice bro ..but trun on/off of the Google less secure setting is mondatary bro

  • @nawabgauhar3377
    @nawabgauhar3377 Год назад

    how to send email verification link using java servlet

    • @TechTutorialCN
      @TechTutorialCN  Год назад

      Generate a has string store them in database. Then send the has to email. Validate the has on get request.

  • @ForeverAnsioso
    @ForeverAnsioso 3 года назад

    why are you retrieving the session 26:56?, you can do it with getRequestDispatcher("/verify.jsp").forward(request, response); no?

    • @TechTutorialCN
      @TechTutorialCN  3 года назад +1

      Yes, actually request dispatcher only work on requested scope. It’s work on limited area. But session is global. In verify page we are hitting our form to new servlet. And there you can’t access the request scope value you have set in previous servlet.

    • @ForeverAnsioso
      @ForeverAnsioso 3 года назад

      @@TechTutorialCN Oh! Really can't reach the previous value? I wanna test it :D, thanks for reply !

  • @manikandant2533
    @manikandant2533 3 года назад +1

    Bro it stuck in..userverify...nothing showing..

    • @manikandant2533
      @manikandant2533 3 года назад

      Please help me with this..

    • @TechTutorialCN
      @TechTutorialCN  3 года назад

      @@manikandant2533 stuck in where?

    • @manikandant2533
      @manikandant2533 3 года назад

      @@TechTutorialCN bro after entering user name and user email..bro...i clicked register and then only it stuck bro..just a white page...help me with this bro..

    • @TechTutorialCN
      @TechTutorialCN  3 года назад

      @@manikandant2533 please check your form action and the ide console whats's the error code.

    • @manikandant2533
      @manikandant2533 3 года назад

      @@TechTutorialCN ok bro..thanks..for ur reply..🥰

  • @TryCodeNowWithMe
    @TryCodeNowWithMe 2 года назад

    error : unable to send mail how to solve

  • @idhayapriyae6293
    @idhayapriyae6293 4 года назад

    Thank you so much!

  • @zanaomar5169
    @zanaomar5169 3 года назад

    I Got this error : javax.mail.AuthenticationFailedException: 535 Authentication credentials invalid

    • @TechTutorialCN
      @TechTutorialCN  3 года назад

      Maybe you are using wrong user email or password

    • @zanaomar5169
      @zanaomar5169 3 года назад

      @@TechTutorialCN both of them are correct

    • @TechTutorialCN
      @TechTutorialCN  3 года назад

      Are you using Gmail?

    • @zanaomar5169
      @zanaomar5169 3 года назад

      @@TechTutorialCN Yes

    • @TechTutorialCN
      @TechTutorialCN  3 года назад

      For security reason goggle refused to authenticate.

  • @gamerandmemer5016
    @gamerandmemer5016 2 года назад

    Less secure app access is disable from 31 may 2022. Any alternative method to solve this. Also I got unknown host exception

    • @TechTutorialCN
      @TechTutorialCN  2 года назад +1

      Please use app password

    • @gamerandmemer5016
      @gamerandmemer5016 2 года назад

      @@TechTutorialCN now it's showing can't send command to host.

    • @Gipsy_T.
      @Gipsy_T. 2 года назад

      found any solution?

    • @TechTutorialCN
      @TechTutorialCN  2 года назад

      Hi, please enable two step verification and use app password from gmail.

    • @Gipsy_T.
      @Gipsy_T. 2 года назад

      @@TechTutorialCN thanks

  • @Ride_Venturer
    @Ride_Venturer 4 года назад

    thanks a lot, this helped a lot.........

    • @TechTutorialCN
      @TechTutorialCN  4 года назад

      I really appreciate that it helps you. I hope you subscribed to my channel😍

  • @pravinj2017
    @pravinj2017 3 года назад

    Getinstance showing error!

    • @TechTutorialCN
      @TechTutorialCN  3 года назад

      What’s error is showing?

    • @pravinj2017
      @pravinj2017 3 года назад

      I think it's a warning in my console that showing like this "Email verification doesn't match with property"

  • @nguyenminhthanhk16_hl40
    @nguyenminhthanhk16_hl40 2 года назад

    Help me, please. I do myself like the way you do but it fails to send email. Then i take your source code, it fails to send email too (but in video your code is still active). How can i do to solve this problem ?

    • @TechTutorialCN
      @TechTutorialCN  2 года назад

      What error you are getting?

    • @nguyenminhthanhk16_hl40
      @nguyenminhthanhk16_hl40 2 года назад

      @@TechTutorialCN It is about the gmail, but i fixed it. Thank you for the video

    • @hnhschannel2116
      @hnhschannel2116 2 года назад

      Mình cũng đang gặp vấn đề không gửi đc email. B có thể chỉ mình cách bạn đã khắc phục được k?

    • @nguyenminhthanhk16_hl40
      @nguyenminhthanhk16_hl40 2 года назад

      @@hnhschannel2116 b kéo xuống bên cmt dưới có người chỉ lỗi 535 hay gì gì đó mà sửa mail thành gmail ấy. Vẫn chưa được nữa thì do gg nó không cho bật cái less secure app access, nên ko gửi được. Mình phải dùng mail edu thì mới gửi đc mail đi.

    • @lethinguyentrinhfpu7677
      @lethinguyentrinhfpu7677 Год назад

      Mình cũng bị giống bạn, bạn đã làm được chưa ? có thể giúp mình được hk ?

  • @wpatyune1631
    @wpatyune1631 4 года назад

    Thanks for this great tutorial, it is god sends 🙏

    • @TechTutorialCN
      @TechTutorialCN  4 года назад

      I am really glad to hear from you.

    • @wpatyune1631
      @wpatyune1631 4 года назад

      @@TechTutorialCN Thanks, your source code didn't put gmail as a host property for the SMTP. :)

    • @TechTutorialCN
      @TechTutorialCN  4 года назад +1

      @@wpatyune1631 for gmail host property is "smtp.gmail.com" and smtp.port and socketfactory.port is 465. and don't forget to turn off two-step verification and less secure app.

  • @Tmixist
    @Tmixist 2 года назад

    javax.mail.AuthenticationFailedException: 535 Authentication credentials invalid

    • @TechTutorialCN
      @TechTutorialCN  2 года назад

      you may use gmail app-password instead of using your original password.

    • @Tmixist
      @Tmixist 2 года назад

      @@TechTutorialCN​ @TechTutorial Hi there, I used mail.com like you did in the tutorial. Not gmail ?

    • @TechTutorialCN
      @TechTutorialCN  2 года назад

      Please double check the password and port