Can i resend mail in java?












1














I have an project use email notify when it finished process.
But sometimes when my computer lost connection to internet, so my process get exception and stop...
So i search the solution of resend the email in JAVA, but i didn't find it.



Does anyone know? JAVA api? or other method~



Thanks for your help!



        Properties prop = System.getProperties();

prop.put("mail.smtp.host", host);
prop.put("mail.smtp.auth", "true");
prop.put("mail.smtp.starttls.enable", "true");
prop.put("mail.smtp.port", port);

Session session1 = Session.getDefaultInstance(prop, new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(from, password);
}
});

Message mailmessage = new MimeMessage(session1);
mailmessage.setFrom(new InternetAddress(from));
mailmessage.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
mailmessage.setSubject(subject);
mailmessage.setText(text);

Transport.send(mailmessage);









share|improve this question






















  • why don' you push your messages in activemq queue?if something happened activemq will take care.
    – GauravRai1512
    Nov 14 '18 at 3:23










  • @GauravRai1512 Because that doesn't give you anything a SMTP server wouldn't do anyway, but adds a lot of unneeded complexity?
    – Robert
    Nov 14 '18 at 3:59










  • Yeah, for that you also have to make connection of your queue with smtp server, flow would be from java code to activemq queue nd then smtp server.so instead of making direct connection with smtp you should use activemq as an interface. It will improve your performance.
    – GauravRai1512
    Nov 14 '18 at 4:14












  • i'll try to use activemq queue. Thank you for providing directions.
    – E Gary
    Nov 14 '18 at 12:40


















1














I have an project use email notify when it finished process.
But sometimes when my computer lost connection to internet, so my process get exception and stop...
So i search the solution of resend the email in JAVA, but i didn't find it.



Does anyone know? JAVA api? or other method~



Thanks for your help!



        Properties prop = System.getProperties();

prop.put("mail.smtp.host", host);
prop.put("mail.smtp.auth", "true");
prop.put("mail.smtp.starttls.enable", "true");
prop.put("mail.smtp.port", port);

Session session1 = Session.getDefaultInstance(prop, new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(from, password);
}
});

Message mailmessage = new MimeMessage(session1);
mailmessage.setFrom(new InternetAddress(from));
mailmessage.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
mailmessage.setSubject(subject);
mailmessage.setText(text);

Transport.send(mailmessage);









share|improve this question






















  • why don' you push your messages in activemq queue?if something happened activemq will take care.
    – GauravRai1512
    Nov 14 '18 at 3:23










  • @GauravRai1512 Because that doesn't give you anything a SMTP server wouldn't do anyway, but adds a lot of unneeded complexity?
    – Robert
    Nov 14 '18 at 3:59










  • Yeah, for that you also have to make connection of your queue with smtp server, flow would be from java code to activemq queue nd then smtp server.so instead of making direct connection with smtp you should use activemq as an interface. It will improve your performance.
    – GauravRai1512
    Nov 14 '18 at 4:14












  • i'll try to use activemq queue. Thank you for providing directions.
    – E Gary
    Nov 14 '18 at 12:40
















1












1








1







I have an project use email notify when it finished process.
But sometimes when my computer lost connection to internet, so my process get exception and stop...
So i search the solution of resend the email in JAVA, but i didn't find it.



Does anyone know? JAVA api? or other method~



Thanks for your help!



        Properties prop = System.getProperties();

prop.put("mail.smtp.host", host);
prop.put("mail.smtp.auth", "true");
prop.put("mail.smtp.starttls.enable", "true");
prop.put("mail.smtp.port", port);

Session session1 = Session.getDefaultInstance(prop, new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(from, password);
}
});

Message mailmessage = new MimeMessage(session1);
mailmessage.setFrom(new InternetAddress(from));
mailmessage.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
mailmessage.setSubject(subject);
mailmessage.setText(text);

Transport.send(mailmessage);









share|improve this question













I have an project use email notify when it finished process.
But sometimes when my computer lost connection to internet, so my process get exception and stop...
So i search the solution of resend the email in JAVA, but i didn't find it.



Does anyone know? JAVA api? or other method~



Thanks for your help!



        Properties prop = System.getProperties();

prop.put("mail.smtp.host", host);
prop.put("mail.smtp.auth", "true");
prop.put("mail.smtp.starttls.enable", "true");
prop.put("mail.smtp.port", port);

Session session1 = Session.getDefaultInstance(prop, new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(from, password);
}
});

Message mailmessage = new MimeMessage(session1);
mailmessage.setFrom(new InternetAddress(from));
mailmessage.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
mailmessage.setSubject(subject);
mailmessage.setText(text);

Transport.send(mailmessage);






java email






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 2:59









E Gary

62




62












  • why don' you push your messages in activemq queue?if something happened activemq will take care.
    – GauravRai1512
    Nov 14 '18 at 3:23










  • @GauravRai1512 Because that doesn't give you anything a SMTP server wouldn't do anyway, but adds a lot of unneeded complexity?
    – Robert
    Nov 14 '18 at 3:59










  • Yeah, for that you also have to make connection of your queue with smtp server, flow would be from java code to activemq queue nd then smtp server.so instead of making direct connection with smtp you should use activemq as an interface. It will improve your performance.
    – GauravRai1512
    Nov 14 '18 at 4:14












  • i'll try to use activemq queue. Thank you for providing directions.
    – E Gary
    Nov 14 '18 at 12:40




















  • why don' you push your messages in activemq queue?if something happened activemq will take care.
    – GauravRai1512
    Nov 14 '18 at 3:23










  • @GauravRai1512 Because that doesn't give you anything a SMTP server wouldn't do anyway, but adds a lot of unneeded complexity?
    – Robert
    Nov 14 '18 at 3:59










  • Yeah, for that you also have to make connection of your queue with smtp server, flow would be from java code to activemq queue nd then smtp server.so instead of making direct connection with smtp you should use activemq as an interface. It will improve your performance.
    – GauravRai1512
    Nov 14 '18 at 4:14












  • i'll try to use activemq queue. Thank you for providing directions.
    – E Gary
    Nov 14 '18 at 12:40


















why don' you push your messages in activemq queue?if something happened activemq will take care.
– GauravRai1512
Nov 14 '18 at 3:23




why don' you push your messages in activemq queue?if something happened activemq will take care.
– GauravRai1512
Nov 14 '18 at 3:23












@GauravRai1512 Because that doesn't give you anything a SMTP server wouldn't do anyway, but adds a lot of unneeded complexity?
– Robert
Nov 14 '18 at 3:59




@GauravRai1512 Because that doesn't give you anything a SMTP server wouldn't do anyway, but adds a lot of unneeded complexity?
– Robert
Nov 14 '18 at 3:59












Yeah, for that you also have to make connection of your queue with smtp server, flow would be from java code to activemq queue nd then smtp server.so instead of making direct connection with smtp you should use activemq as an interface. It will improve your performance.
– GauravRai1512
Nov 14 '18 at 4:14






Yeah, for that you also have to make connection of your queue with smtp server, flow would be from java code to activemq queue nd then smtp server.so instead of making direct connection with smtp you should use activemq as an interface. It will improve your performance.
– GauravRai1512
Nov 14 '18 at 4:14














i'll try to use activemq queue. Thank you for providing directions.
– E Gary
Nov 14 '18 at 12:40






i'll try to use activemq queue. Thank you for providing directions.
– E Gary
Nov 14 '18 at 12:40














1 Answer
1






active

oldest

votes


















1














Install SMTP service on computer, then set mail.smtp.host to localhost.



The SMTP service will attempt to resend email, until it gives up (configurable).






share|improve this answer





















  • so i use my computer as a SMTP server?
    – E Gary
    Nov 14 '18 at 12:36










  • @EGary You'll just be using your machine as an SMTP relay server, only allowing relay from local apps, i.e. it won't be open to spam hackers.
    – Andreas
    Nov 14 '18 at 16:15











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%2f53292561%2fcan-i-resend-mail-in-java%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









1














Install SMTP service on computer, then set mail.smtp.host to localhost.



The SMTP service will attempt to resend email, until it gives up (configurable).






share|improve this answer





















  • so i use my computer as a SMTP server?
    – E Gary
    Nov 14 '18 at 12:36










  • @EGary You'll just be using your machine as an SMTP relay server, only allowing relay from local apps, i.e. it won't be open to spam hackers.
    – Andreas
    Nov 14 '18 at 16:15
















1














Install SMTP service on computer, then set mail.smtp.host to localhost.



The SMTP service will attempt to resend email, until it gives up (configurable).






share|improve this answer





















  • so i use my computer as a SMTP server?
    – E Gary
    Nov 14 '18 at 12:36










  • @EGary You'll just be using your machine as an SMTP relay server, only allowing relay from local apps, i.e. it won't be open to spam hackers.
    – Andreas
    Nov 14 '18 at 16:15














1












1








1






Install SMTP service on computer, then set mail.smtp.host to localhost.



The SMTP service will attempt to resend email, until it gives up (configurable).






share|improve this answer












Install SMTP service on computer, then set mail.smtp.host to localhost.



The SMTP service will attempt to resend email, until it gives up (configurable).







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 14 '18 at 3:19









Andreas

75.1k459122




75.1k459122












  • so i use my computer as a SMTP server?
    – E Gary
    Nov 14 '18 at 12:36










  • @EGary You'll just be using your machine as an SMTP relay server, only allowing relay from local apps, i.e. it won't be open to spam hackers.
    – Andreas
    Nov 14 '18 at 16:15


















  • so i use my computer as a SMTP server?
    – E Gary
    Nov 14 '18 at 12:36










  • @EGary You'll just be using your machine as an SMTP relay server, only allowing relay from local apps, i.e. it won't be open to spam hackers.
    – Andreas
    Nov 14 '18 at 16:15
















so i use my computer as a SMTP server?
– E Gary
Nov 14 '18 at 12:36




so i use my computer as a SMTP server?
– E Gary
Nov 14 '18 at 12:36












@EGary You'll just be using your machine as an SMTP relay server, only allowing relay from local apps, i.e. it won't be open to spam hackers.
– Andreas
Nov 14 '18 at 16:15




@EGary You'll just be using your machine as an SMTP relay server, only allowing relay from local apps, i.e. it won't be open to spam hackers.
– Andreas
Nov 14 '18 at 16:15


















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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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%2f53292561%2fcan-i-resend-mail-in-java%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

How to pass form data using jquery Ajax to insert data in database?

National Museum of Racing and Hall of Fame

Guess what letter conforming each word