How to access the email accounts in third party application in android? - java

I am creating an application to access a GMail account and some other EMail accounts that are not GMail. How can I access the inboxes of those email accounts my application?

I assume the following:
You want to use Java.
You are trying to retrieve a list of emails.
You need to do this for GMail and non-GMail accounts.
You didn't mention anything about persisting the mails on your device, so I assume you want a quick snapshot of the inbox.
You didn't mention whether you want to leave the emails in the inbox or delete them upon retrieval, so you need a choice concerning that option.
You have no knowledge how fetching EMails works technically.
So first you need to decide on how to access the mails. As you need to access GMail and non-GMail accounts, it seems that accessing the mails via POP3 would be a natural fit. "Usually" this access method will also delete the mails from the users inbox, but there is an option to download mails without deleting them. Authenticating via POP3 is handled in numerous ways, so I would go for a library that does this for you.
I am neither an Android Developer nor do I have much to do with Java outside of JSF, but the Java Mail API seems to be capable of doing POP3 retrieval. And there is an implementation for Android.
Apart from that, your GUI might be missing a possibility to specify a server, a port and an option to pick the relevant encryption. You can of course "guess" these parameters from the given domain of the users email address, but you will need this information to retrieve the emails.
And of course you could also use IMAP, which the Java Mail API also seems to be capable of.

Related

How can I use API server side to provide datas from my account to a google signed in user?

I'm using angular, google app engine and JAVA on the backend server.
User can authenticate without problem with an opendId connect URL where code is passed back to my server to authenticate.
Now what I wan't to do is send mail to user (refresh password, confirm account mail) and to myself (server error message) with my account myaccount#gmail.com.
Also I have sheets I need user to write and read datas to/from. Magically I've made it worked as an installed offline app (only 1 api at a time, I never made the two worked together).
I've tried service account but from a last post somebody explained me that in order to make gmail work I needed a g suite account which I don't have and suggest me to go through oAuth2 authentification. Now the question is how can I implement that in java with a single authentification, I explain, I wan't to authorize app to have access to certain scopes but it should be only be authorized once because I don't want user to have a consent screen popup and even if they had they couldn't authenticate as it is on the behalf of my personnal account. I don't think I can use installed app for a google app engine app but maybe I'm wrong.
just to let you know I have tried lot's of different manners and spent about 3/4 days trying to find a solution without clearly understanding/finding what to do.
Any help is greatly appreciated please let me know if you need more explanations or code.
I think you are missing a few key concepts here.
DATA
There are two types of data private user data and public data. Private user data is owned by a user and there for you must have permission or concent to access it. Public data is data that is owned by anyone.
Oauth2
Oauth2 is the protocol we use to request connect from a user for our applications to access their data. A user can grant you access to their gmail account and their google drive account granting you access to the sheets on their account.
Service accounts
Service accounts are preapproved dummy users. As a developers we can create service accounts and grant them access directly to our drive account then the service account will then be able to access to the data without being requiring consent as it already has pre approved access. (not all google apis support service accounts. gmail (with the exception of gsuite) and YouTube are two that dont)
What you are trying to do
However i do not understand why you want to use the users gmail account to send them an email. If you want to send them an email i would think you would be using your own email system.
If what you are trying to do is use your gmail account to send users of your application emails from YOU. Then you should consider going directly though the SMTP server to your own account. Having an application that uses the gmail api is one of the scopes that will be flagged by google when you try to get your application approved. You are going to be going though a lot of red tape with them to show why you need access to a users gmail account.

Collecting an email address for Text Box in Android?

In my new app, i would like to have a text dialog where the user can enter their email address to subscribe to our newsletter and to hear of new updates, features to come.
I am already familiar with using Text dialogs in android.
My question is, when the user hits submit, i would like for the users information entered to be sent to my website or maybe written to a file on my website.
OR is there a way i can have it sent to my email some how? If i could some how add them to a spreadsheet that would also be nice.
At this point i am open to any option that would work and not to difficult to implement.
I dont own a server, but i do have a website with storage space etc through GoDaddy.
Thanks guys.
It depends on how much work you want to do, and how much security you want.
If you go with the email option, your application will need a valid email address, password, and server to send email from. This means you will need to embed those variables within your application, and it could be abused.
If you want the address to be written on a file on your website, you will have to allow FTP access within your application, which is another security concern and will increase the amount of code your application needs to work.
The best solution for this scenario would be to have a servlet running on your webserver that can securely communicate with a database. Your Android application can call an HTTP POST message to your servlet containing the user's email address, and the servlet can then save it to a database, which you can pull a spreadsheet from.
This will be the fastest and most secure way of accomplishing what you're wanting.

Send message from server-side(Java) to Facebook users

I've a site that performs a lot of processings asynchronously, and in certain moments, should to send private messages to users that previously have installed the Facebook app of my site.
Is it possible to send messages from server-side (Java) directly to these users?
Thanks.
This is not possible, if it was, imagine the amount of spam Facebook users would be receiving.
Alternatively, you can access their emails (with the appropriate permission), and use that instead.

creating an email account on mail server by mail api

I am creating a web application in which i need to create a form by which user can create an email id on mail server. This is like any email service provider do, like gmail(for creating an email account on their site).
I am new to java mail api. Can anyone provide any hint for this.
Any help will be appreciated.
Thanks...
Actually what i want is a sign up form like what gmail or others provides to create an email id account on their servers.
for developing purpose i m using *hmailserve*r.
manually i can create email ids on this server but i want this in programmatic way.
I don't think JavaMail will help here. First, it depends on the mail server you use. Every mail server has different ways to manage user accounts. For example with Postfix you can manage user accounts in a MySQL database (like in that tutorial). Then you just would have to create database entries. Other mail servers may manage the accounts in a textfile.
AFAIK you can't do it using java mail api alone, you'll need and API for the specific mail server you are using.
Java Mail API will help you out in this. Try these links:
http://www.mkyong.com/java/javamail-api-sending-email-via-gmail-smtp-example/
http://javamail.kenai.com/nonav/javadocs/index.html

how can a registered member only can access my company website from android phone

i want my company website to access from my android phone but that website can only be accessed by registered member
i have login page in that i have to enter registered email and passwrd than directly from the login page only i have to redirect to my company web url ???
Please give suggestion
Thanks in advance
Edited, to be more explicit :
How to secure and restrict access to a website ?
Restrict network access
Maybe the simpliest solution. A web site is not always available on the internet or for everybody. In fact if your website sit in some machine in your company office, make it available on the net require more effort than just let local computers access to it.
What does that mean ? You configure your firewall and your network to allow access of your server for only some IP address/port. To continue on this network only solution, you can create a VPN that include your mobile phone devices.
Include authentification and authorization management directly in the application
The first solution is a first pass. It allow you to forbidd access to most people out of your organisation. But maybe you want more, you want for exemple that only people from marketing do have access to the web site. Or maybe you want depending of the user (or user group), allow them to do differents things.
The best way to do that is to directly manage uses rights into your website. You authenticate users, and when a specific functionnality is requested your firt verify is user has credential.
If you already have an IT department, it is likely that a directory is available with all users, their password and their groups. You can base your check on the directory, avoiding the harsle to create/delete users in your application directly.
Using a proxy to secure or authenticate access
This solution is like a melt of the other ones. First you make sure sure using network restriction that your web site is only accessible using the proxy machine (so only one IP basically). Then you use a web server (like Apache HTTPD server) as a proxy, or a gateway to access the website.
Basically, when a user want to request your website, it doesn't directly ask the application that manage it, but the proxy. Because the application server is isolated in the network, it doesn't have to be secured.
The proxy allow you to fine tune the behaviour of your web site :
you can add encryption using SSL to
all data that transit from the client
to server, so no senssible data is
sent unprotected
you can compress all data that
transit to optimize the bandwidth
usage (really important for mobile
device and their not so good
internet connexion).
you can use HTTP authentification to
check user has the right to access
to the page. This can be just a
login/password check, or a client
certificate to fully secure the
connexion, allowing only device
with the certificate to be granted
access.
You can tune access per group to certain part of the site, but this is not as flexible as retrictions done directly by the web site application.
Didn't catch you very well. Do you mean that you want your company website can just be accessed by android phone for registered member? If so, I think you can check what browser type can be used in android phone, and in your website check it from http request, like "String browserType=(String)request.getHeader("User-Agent");" .

Categories

Resources