Send emails in Spring Boot apps [Intermediate Spring Boot]

Công Nghệ

How to send emails in Spring Boot applications

In this Spring Boot tutorial you will learn:
– how to add the starter email dependency to a Spring Boot project
– how to parametrize the connection to your email server
– how to encapsulate the email server parameters in a reusable and injectable class
– how to send emails from a REST controller method
– how to test email features using Mailtrap


Check out the latest programming articles on my blog:


Say hi on social:



Xem thêm bài viết khác:

24 thoughts on “Send emails in Spring Boot apps [Intermediate Spring Boot]

  1. This is a tool that allows you to send bulk mail by a few simple steps: Zvýšila míru využití jedné bezplatné poštovní schránky a zvýšila celkový počet dodávek za den.

  2. {

    "timestamp": "2019-12-19T12:19:02.059+0000",

    "status": 500,

    "error": "Internal Server Error",

    "message": "Mail server connection failed; nested exception is com.sun.mail.util.MailConnectException: Couldn't connect to host, port:, 2525; timeout -1;n nested exception Connection timed out: connect. Failed messages: com.sun.mail.util.MailConnectException: Couldn't connect to host, port:, 2525; timeout -1;n nested exception Connection timed out: connect",

    "path": "/feedback"

    } I am getting the following error please help me

  3. Hi .. My problem: In   in line 1,  I  have not the "green arrow"  and then I can't "RUN"… Can you help me ?

  4. how do I send email to my personal email address? no matter what I put on setTo its always sending email to

  5. I'm getting the error: "Cannot find symbol class Email" in the Feedback class. On line 3:
    import javax.validation.constraints.Email;
    Perhaps maven has downloaded a newer version of spring-boot-starter-mail where there is no such class? Any suggestions?

  6. hi, I followed your auto but I did not receive the email even throw I found the email in the box

  7. Hi, i dont have any errors but when i run a "POST" in postman it just hangs and never fails or succeeds.
    Any pointers?

  8. Nice video buddy, but your annotation @Min using is not correct, for string length validation, you should have used @Size. In your restController, you missed @Valid, or your BindingResult class will not work.

  9. I tried to run same code by changing my credentials of mailtrap .
    But neither I am getting any message in inbox nor any error .
    can you let me know Is there other changes I need to do .

    Thanks !

  10. Very great tutorials brother! If possible, could you please implement spring security with angular? I have been struggling for so long. Thanks.

  11. As usual an awesome and very useful tutorial. Thanks for posting great content like this, keep going!

    All your Spring Boot tutorials are a blessing and you're the one who motivated me to learn Spring Boot with your excellent series of tutorials to create the Booking app a year ago. Today I'm creating a complete website for a startup and this tutorial helped me for one feature I had to implement.

    Thanks again!

  12. I hadn't noticed this other playlist! Great to see you've been creating more Spring Boot Videos! thanks for sharing these!

Leave a Reply

Your email address will not be published. Required fields are marked *