Send Email using Spring BootSending email in .NET through GmailHow to validate an email address in JavaScript?How to validate an email address using a regular expression?How to configure port for a Spring Boot applicationMail sending -SMTP error with javaMailSenderSending email from Spring Boot application using GmailJava spring boot - JavaMailSender errorsSpring Boot email sending throws SocketTimeoutException: Read timed outsmtp.gmail.com exceptions, enable to send emailSpring Boot - Sending Email using Gmail

When to remove insignificant variables?

Methodology: Writing unit tests for another developer

Improving triangulation on AutoCAD-generated stl files

Can any NP-Complete Problem be solved using at most polynomial space (but while using exponential time?)

Silly doubt about tidal effects and Einstein Field Equations

How does the spell Remove Curse interact with a Sword of Vengeance?

Can humans ever directly see a few photons at a time? Can a human see a single photon?

Is it safe to connect a PoE injector switch to an ordinary PC?

Can Ogre clerics use Purify Food and Drink on humanoid characters?

Should developer taking test phones home or put in office?

Do I have to explain the mechanical superiority of the player-character within the fiction of the game?

Would it be a copyright violation if I made a character’s full name refer to a song?

Understanding the reasoning of the woman who agreed with King Solomon to "cut the baby in half"

Drawing people along with x and y axis

How to find the last non zero element in every column throughout dataframe?

Array initialization optimization

If I wouldn't want to read the story, is writing it still a good idea?

How is hair tissue mineral analysis performed?

Helping ease my back pain when I'm studying 13 hours everyday, even weekends

How do I turn off a repeating trade?

What's the difference between a deep fryer and a chip pan?

Loss of power when I remove item from the outlet

How did Bellatrix know about the Philosopher's Stone?

How to draw this center trajectory of rolling ball?



Send Email using Spring Boot


Sending email in .NET through GmailHow to validate an email address in JavaScript?How to validate an email address using a regular expression?How to configure port for a Spring Boot applicationMail sending -SMTP error with javaMailSenderSending email from Spring Boot application using GmailJava spring boot - JavaMailSender errorsSpring Boot email sending throws SocketTimeoutException: Read timed outsmtp.gmail.com exceptions, enable to send emailSpring Boot - Sending Email using Gmail






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-1















I made a little application to send email with attemet using spring boot, at the first it works, then I had port problem :




"Couldn't connect to host, port: smtp.gmail.com, 587; timeout -1"




I tried to change the port to "465".

But I have found the same problem.

What's the matter?

Thanks










share|improve this question



















  • 3





    Please add code part

    – Usman
    Mar 25 at 8:49

















-1















I made a little application to send email with attemet using spring boot, at the first it works, then I had port problem :




"Couldn't connect to host, port: smtp.gmail.com, 587; timeout -1"




I tried to change the port to "465".

But I have found the same problem.

What's the matter?

Thanks










share|improve this question



















  • 3





    Please add code part

    – Usman
    Mar 25 at 8:49













-1












-1








-1








I made a little application to send email with attemet using spring boot, at the first it works, then I had port problem :




"Couldn't connect to host, port: smtp.gmail.com, 587; timeout -1"




I tried to change the port to "465".

But I have found the same problem.

What's the matter?

Thanks










share|improve this question
















I made a little application to send email with attemet using spring boot, at the first it works, then I had port problem :




"Couldn't connect to host, port: smtp.gmail.com, 587; timeout -1"




I tried to change the port to "465".

But I have found the same problem.

What's the matter?

Thanks







spring-boot email






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 10:06









Vadim Kotov

5,15473550




5,15473550










asked Mar 25 at 8:40









pro educationpro education

12




12







  • 3





    Please add code part

    – Usman
    Mar 25 at 8:49












  • 3





    Please add code part

    – Usman
    Mar 25 at 8:49







3




3





Please add code part

– Usman
Mar 25 at 8:49





Please add code part

– Usman
Mar 25 at 8:49












1 Answer
1






active

oldest

votes


















0














I`m using spring-boot-starter-mail 2.0.4.RELEASE in this code.



I use this Configuration for smtp.gmail.com.



@Configuration
public class EmailSenderConfig

@Value("$mail.login")
private String login;

@Value("$mail.password")
private String password;

@Bean
public JavaMailSender getJavaMailSender()
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost("smtp.gmail.com");
mailSender.setPort(587);

mailSender.setUsername(login); //login for google account "this.my.email@gmail.com"
mailSender.setPassword(password); // password for google account "thisMyPassword666"

Properties props = mailSender.getJavaMailProperties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.debug", "true");

return mailSender;




And this code for sending messages



@Autowired
private JavaMailSender mailSender;

public void sendToken(String to)
SimpleMailMessage smm = new SimpleMailMessage();

String token = String.valueOf(new Random().ints(MIN, MAX).findFirst().getAsInt());

verificationService.saveTemporaryToken(to, token);

smm.setTo(to);
smm.setSubject(TITLE);
smm.setText(token);

mailSender.send(smm);



Compare my code and your, maybe you forgot to write something.






share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55333947%2fsend-email-using-spring-boot%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I`m using spring-boot-starter-mail 2.0.4.RELEASE in this code.



    I use this Configuration for smtp.gmail.com.



    @Configuration
    public class EmailSenderConfig

    @Value("$mail.login")
    private String login;

    @Value("$mail.password")
    private String password;

    @Bean
    public JavaMailSender getJavaMailSender()
    JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
    mailSender.setHost("smtp.gmail.com");
    mailSender.setPort(587);

    mailSender.setUsername(login); //login for google account "this.my.email@gmail.com"
    mailSender.setPassword(password); // password for google account "thisMyPassword666"

    Properties props = mailSender.getJavaMailProperties();
    props.put("mail.transport.protocol", "smtp");
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.debug", "true");

    return mailSender;




    And this code for sending messages



    @Autowired
    private JavaMailSender mailSender;

    public void sendToken(String to)
    SimpleMailMessage smm = new SimpleMailMessage();

    String token = String.valueOf(new Random().ints(MIN, MAX).findFirst().getAsInt());

    verificationService.saveTemporaryToken(to, token);

    smm.setTo(to);
    smm.setSubject(TITLE);
    smm.setText(token);

    mailSender.send(smm);



    Compare my code and your, maybe you forgot to write something.






    share|improve this answer



























      0














      I`m using spring-boot-starter-mail 2.0.4.RELEASE in this code.



      I use this Configuration for smtp.gmail.com.



      @Configuration
      public class EmailSenderConfig

      @Value("$mail.login")
      private String login;

      @Value("$mail.password")
      private String password;

      @Bean
      public JavaMailSender getJavaMailSender()
      JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
      mailSender.setHost("smtp.gmail.com");
      mailSender.setPort(587);

      mailSender.setUsername(login); //login for google account "this.my.email@gmail.com"
      mailSender.setPassword(password); // password for google account "thisMyPassword666"

      Properties props = mailSender.getJavaMailProperties();
      props.put("mail.transport.protocol", "smtp");
      props.put("mail.smtp.auth", "true");
      props.put("mail.smtp.starttls.enable", "true");
      props.put("mail.debug", "true");

      return mailSender;




      And this code for sending messages



      @Autowired
      private JavaMailSender mailSender;

      public void sendToken(String to)
      SimpleMailMessage smm = new SimpleMailMessage();

      String token = String.valueOf(new Random().ints(MIN, MAX).findFirst().getAsInt());

      verificationService.saveTemporaryToken(to, token);

      smm.setTo(to);
      smm.setSubject(TITLE);
      smm.setText(token);

      mailSender.send(smm);



      Compare my code and your, maybe you forgot to write something.






      share|improve this answer

























        0












        0








        0







        I`m using spring-boot-starter-mail 2.0.4.RELEASE in this code.



        I use this Configuration for smtp.gmail.com.



        @Configuration
        public class EmailSenderConfig

        @Value("$mail.login")
        private String login;

        @Value("$mail.password")
        private String password;

        @Bean
        public JavaMailSender getJavaMailSender()
        JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
        mailSender.setHost("smtp.gmail.com");
        mailSender.setPort(587);

        mailSender.setUsername(login); //login for google account "this.my.email@gmail.com"
        mailSender.setPassword(password); // password for google account "thisMyPassword666"

        Properties props = mailSender.getJavaMailProperties();
        props.put("mail.transport.protocol", "smtp");
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.starttls.enable", "true");
        props.put("mail.debug", "true");

        return mailSender;




        And this code for sending messages



        @Autowired
        private JavaMailSender mailSender;

        public void sendToken(String to)
        SimpleMailMessage smm = new SimpleMailMessage();

        String token = String.valueOf(new Random().ints(MIN, MAX).findFirst().getAsInt());

        verificationService.saveTemporaryToken(to, token);

        smm.setTo(to);
        smm.setSubject(TITLE);
        smm.setText(token);

        mailSender.send(smm);



        Compare my code and your, maybe you forgot to write something.






        share|improve this answer













        I`m using spring-boot-starter-mail 2.0.4.RELEASE in this code.



        I use this Configuration for smtp.gmail.com.



        @Configuration
        public class EmailSenderConfig

        @Value("$mail.login")
        private String login;

        @Value("$mail.password")
        private String password;

        @Bean
        public JavaMailSender getJavaMailSender()
        JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
        mailSender.setHost("smtp.gmail.com");
        mailSender.setPort(587);

        mailSender.setUsername(login); //login for google account "this.my.email@gmail.com"
        mailSender.setPassword(password); // password for google account "thisMyPassword666"

        Properties props = mailSender.getJavaMailProperties();
        props.put("mail.transport.protocol", "smtp");
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.starttls.enable", "true");
        props.put("mail.debug", "true");

        return mailSender;




        And this code for sending messages



        @Autowired
        private JavaMailSender mailSender;

        public void sendToken(String to)
        SimpleMailMessage smm = new SimpleMailMessage();

        String token = String.valueOf(new Random().ints(MIN, MAX).findFirst().getAsInt());

        verificationService.saveTemporaryToken(to, token);

        smm.setTo(to);
        smm.setSubject(TITLE);
        smm.setText(token);

        mailSender.send(smm);



        Compare my code and your, maybe you forgot to write something.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 25 at 10:37









        zdadcozdadco

        685




        685





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55333947%2fsend-email-using-spring-boot%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript