Auto Generated Mail - java

Perhaps this kind of question comes under not to ask category but for the sake of application I have to ask.So pardon me.
At the time of Log in,I found that(suppose)If I am unable to remember my password,then I have to put my email-id then an auto generated reply come from that's hosted site with
a new link for generating another new password or
simply sending password(that means password isn't encrypted,I guess) in reply.
watching the source code it's hard to predict,but I want to know(if they are using jsp) then which protocol is used for this auto generated mail what are the other things to remember to achive this, while I'm also making an application for auto generated mail.

I have done this using javax.mail api in java
google for sending mail using java...
define content of mail in template or resource file and send mail whenever user clicks on forgot password link.
It is using SMTP protocol only.

Related

Test Reset Password functionality with selenium and dummy email server

Im searching all day online to find an answer to this issue im having during my selenium testing.
Im trying to test if is it possible to test my sites reset password functionality while using a dummy email server. I understand I may have to use javamail (I think) for this but wanted to know if anybody knew of any possible way to maybe use a dummy email server like mailtrap or something like that, select the reset password link, reset the password and log back into my account using the new password??
Im using selenium and java for my tests.
PutsBox
seems to be the anwser to your question. It's a great, easy to use tool for testing your emails via GUI.
How does this piece of joy work?
Send an email to whatever-recipient-you-want-to#putsbox.com, give it a few seconds (don’t blame PutsBox, email delivery services may take a few seconds) then check https://preview.putsbox.com/p/whatever-recipient-you-want-to/last, voalá, it will respond with your email content. You can also append .json to that URL to get the JSON representation.
No sign up required, PutsBox is free and open source.
Basically - register your User as you would with an email such as emailAddress#putsbox.com, then you can check the newest (very important, only the newest) email sent to that account by going to https://preview.putsbox.com/p/emailAddress/last.
As it is a webpage you can use Selenium and check all the elements you want in that email.

How to send email with registration link for confirmation of new user using JSP and servlet?

I am doing a project where I want a mail to be sent to a new user with a link for confirmation and after clicking that link then only he can access his profile.
After many types of research, I am unable to find a proper answer on how to implement this in my project.
I am using JSP and servlet for development in localhost. I hope here I will get the proper solution for my problem.
Question is too broad.. In order to achieve your requirement we need to do multiple things
Need smtp server
Send Email though Java using smtp
generate a unique key, encrypt it and add it to registration link (http://www.myxyz.com?sId=XXXXXXXXXXX) and save non-encrypted key in database (you need some kind of cross verification process)
when user clicks link, grab the key and decrypt it and validate the key with key in database
In order to achieve item-2 follow http://www.javatpoint.com/example-of-sending-email-using-java-mail-api
I used following way to generate unique key (item-3)Efficient method to generate UUID String in JAVA (UUID.randomUUID().toString() without the dashes)
item-4: Implement logic on server side (Servlet is best option)

Java outlook integration

I have a program that must 'prepare' emails for me. When the email is prepared, it should show in outlook (or an other email client - default user mail client).
I have used the Desktop.getDesktop().mail approach, but I'm very limited with the options. (I cannot set the high importance). An other option I've tried is JavaMail. But here the mail will be send instead of opened in the email client. (same for Apache POI).
An other option I've considered is to write a .msg/.eml file and open it, but this must be done manually (via java I get a 'file not found' error or an error regarding privileges).
Does anyone know other options or other approaches I might have missed / overlooked?
You can make use of moyosoft's connector to access outlook functionality from java. Please refer to below url's for more details on this.
http://www.moyosoft.com/joc/
http://www.moyosoft.com/joc/getstarted/

Best way to send an E-Mail from a java Application

I've been searching for the best way to send an e-mail with an attachment by my java application. I want to use this as an users bug report with logger files. The recipient should be my own e-mail address. I'd prefer the use of an e-mail client.
I tried the following:
Send an e-mail with user authentification like this. I don't want to use this, because the user would need to reveal his e-mail account and password. Furthermore, I'd have to set the properties for every e-mail adress, which is impossible.
Send an e-mail directly to my own e-mail address like this in Listing 16.16 (didnt found an english example). The problem is every e-mail server is using POP authentification nowadays, that means the recipient e-mail server won't accept my e-mail.
Using the mailto URL syntax like this. Doesn't work aswell, because the attachment function isn't working properly in every e-mail client. Best solution so far is to brief the user to add the attachment by himself, after I would put it to his desktop. Or upload the data and add a link to the e-mail body.
The last way I've found is this one. As you could assume this won't work either, because the localhost needs to be connected to the internet and capable enough to send an e-mail.
Hopefully I explained my problem well enough. Is there a different way to send bug reports?
The generally accepted way to get around the problems you describe is to keep all the email logic server side, and then have your application call a web service with the appropriate parameters. It's pretty easy to knock a PHP script / servlet up that will do the job and then send the results on via email, put them in a mysql database or so on.
However, if you can't / don't want to / won't keep this server side, I'd recommend using JavaMail to create a MimeMessage, then using writeTo() to write this to an EML file.
You can then do the usual:
Desktop.getDesktop().open(emlFile);
...which will open the EML file with the default application for handing those files, which is almost always the mail client. Still not foolproof, but if you're determined on sending the email from the client directly I think that's as good as you'll get.

How to retrieve email body of any email, using Java Mail API

I am developing a Mail Client in Java (JSP and Struts). I have successfully fetched Message header information and stored in my local Database (including Message ID and subject).
When the user views the mails, I fetch the message headers from my database and display them to user. Now when the user click a particular Email, I want to fetch the mail body and file attachments from the Gmail server, directly. I don't want to serially travel through all the mails on the Gmail Server.
I have done this earlier in PHP, where if I pass the message id and I can retrieve the details of that particular mail. Is there any similar functionality in Java Mail API? If not, then can anyone suggest me a solution to this?
You can use Folder#getMessage(int) for this.
Note that the zip file with the JavaMail API which you can download from their side includes a lot of examples in /demo folder, under each a basic(!) Servlet which shows a simple mailbox with this functionality. You may want to build, refactor and expand further based on the simple example.

Categories