Java Mail being blocked by gmail in some cases - java

I have a running and working implementation of the Java Mail API. I am using the api to send out bulk email messages. On some occasions, the login gets blocked by google. So, I go to my gmail account and allow access to apps and set the security level to give access to apps that don't use what google calls "modern security". So, the google page tells me to try my program again. I try it again and it still won't let me log in. On some occasions when I have a login fail, I can go to the account, log in, and type in the recaptcha. This will allow me to log back in shortly after and send emails. However, the problem I am now experiencing does not show any recaptcha, nor does it say anything about any unknown apps that tried to access the account. It says nothing, and just wont let me log in to my account. I created two new accounts for testing and they worked fine. The account that I created that doesn't work only allowed me to send 17 emails before it blocked my service. Does anyone have any suggestions? Thanks!

Go to your Gmail account setting page and Enable access of Less secure apps. Then try with Java Mail API. Hope it works for you.

Make sure that your JavaMail with google auth is working fine, Check concurrently with Different app. If not post your code

If you're using a free Gmail account, Google might think your bulk email is spam (duh). If you're going to send bulk email, it may be time to pay someone for a business account that will let you do that.

Related

App Permission declaration form rejected by Google

I recently received the notification from google that my app uses some of the permissions that are not necessary so I need to submit a declaration form .So I submitted the declaration form .
They asked these questions so I replied this:-
1: In one sentence, please describe the core functionality of your app.
This is an security app, app uses sms in sense when there is not internet, app will send sms after asking user and giving full awarness about the sms sending, sms only will be send when user need not intensively, and will send to only user declear person whom user want to send
2: What is the core functionality in your app requiring the Call Log and / or SMS permissions?
Connected device companion apps that enable send and receive of SMS or calls [SEND_SMS, WRITE_SMS, RECEIVE_SMS, RECEIVE_MMS, READ_SMS, READ_CALL_LOG, PROCESS_OUTGOING_CALLS, WRITE_CALL_LOG], N/A
4: Do any of the following other use cases apply to your app’s core functionality request for Call Log or SMS permissions?
Physical safety or emergency alerts.
After few Days I got this reply
We reviewed your request and found that your app does not qualify for use of the requested permissions for the following reasons:
The declared functionality {CONNECTED_COMPANION_DEVICES} is determined to be unnecessary or not aligned with the core functionality of your app.
It looks like you are using SMS/Call Log permissions group for functions that might qualify for exceptions: {SAFETY_EMERGENCY_ALERT}.
Please declare it in the declaration and resubmit the form.
Please Tell me is there any solution to fix it ? What changes I need to make in my code?
The first app that I developed and put on the playstore (very ugly) did exactly what yours does and so I received YOUR SAME NOTICE.
In fact, I am at the next step as I have started a "challenge" to request an exception.
They answered me like this:
SMS / Call Log permissions group for ineligible functions: {Device Locator}
.... but my app is a DEVICE LOCATOR! It's its main feature!Mahh
I suggest you do, as I did, by replying to the e-mail and saying if the localization apps are allowed or not via sms ... there is no written anywhere in the policies that is not allowed.

Automatically reply to an email

I'm working on a project I'm Java with regards to outlook.
Here I'm able to do all the functions like Read a mail, write a mail, reply to a mail etc...
But now we've been thinking of taking it to the next level.
Our plan is as below.
We have an email address like info#myDomain.com, when ever an email is sent to this address, I need to reply them. Here basically customers send an email asking for some data, and we've the data available in our portal, and we just need to send it.
The response would be Like thank you for contacting us, we will get back to you soon. Mean while please look into this {URL}.
And this has to be done automatically when ever there is an email hit to this particular email address.
Couple of questions:
- should my machine be on the whole day to get this thing done.
- is there a way that a Java application can automatically monitor my inbox to see for this case match.
- Also, can I have this running in the bg.
Can someone please point me into the right direction/approach where can I can start working on this task.
Thanks
when ever an email is sent to this address, I need to reply them.
For this you need to monitor your email account fro incoming emails. Here is one of the way to do this
The response would be Like thank you for contacting us, we will get back to you soon. Mean while please look into this {URL}.
Once you receive an email (using above email monitoring approach), you need to call a method that sends the reply with above format
And this has to be done automatically when ever there is an email hit to this particular email address.
Above two steps accomplishes this task.
should my machine be on the whole day to get this thing done
Basically, you will need an application server (like tomcat) where your above java program is deployed. So, yes this server needs to be running and available all the time.
is there a way that a Java application can automatically monitor my inbox to see for this case match
Check point 1
Also, can I have this running in the bg
You can run tomcat as a service in windows (more info). It has many advantages, automatic startup on boot being the one. Similar implementations are also available for other OS.
So, in short, this can be accomplished. It is bit complex but not much difficult. Cheers

What and how should i use to send error logs from my java program onto a server (mail, git, etc...)

I have an alpha staged program with many bugs, and I would like to let people send their logs on a server (mail, git, etc...) so i can look them up and fix them. I have searched allot on this topic and I haven't found a way to do it without downloading a git full of logs, or needing an authentication for a mail or a dedicated server.
Is there a way to make my Java program send automatically its error log on a server when it crashes, without needing costly hardware or authentification? (i have a 0$ budget).
A free Loggly account sounds perfect for your needs.
You could use the javamail library to send emails to an account where you want to get the errorlogs. This wouldn't cost anything. And is very fast to implement/integrate in your project.
I would suggest to create a new gmail account which will send the emails to your account, where you want to recieve and debug it.

Java How to send an email/sms from a Users computer

I want to send a User an email or SMS to his SmartPhone when an Alert happens on his desktop App.
How can I send an email WITHOUT supplying my log-in credentials within the App?
using smtp I need to provide my credentials, but as this is for a published application that does not sound like a good idea.
I understand this is a very general question, but I am having trouble finding a solution on the web.
I'm sorry, but you will not be able to do this, as the smtp server requires some sort of authentication, from which to send from

What is needed to add emailing capabilities to web application?

I have java web application to which I'd like to add emailing capabilities, however, I'm unsure what is needed to accomplish this. Specifically I want my app to be able to:
Send emails confirming sign-up
Allow users to send emails to one another, using my app's domain i.e. dan#my-app.com
From my research it seems I'll need a mail transfer agent (MTA) like Postfix and possibly a IMAP server like Courier; but I don't understand the need for the IMAP server.
Thanks.
You need code inside your web app to create and dispatch the email into the SMTP-world. Usually JavaMail is used for this, and you can either enclose it in your web application or (preferred) have the web container provide a correctly configured instance through JNDI. This is vendor specific.
If you do not have a SMTP-server for JavaMail to connect to (frequently this is Exchange for Windows shops), you can either get one running (ask your IT administrator) or use Google Mail or Hotmail or others if it is ok for your web application to send mail through them. It is a bit tricky to use GMail as a SMTP-server, but when set up correctly works very well.
You will need the SMTP-server, as it handles all the boring details regarding MX records and resending if the SMTP-server does graylisting, etc. etc.
Oh, and IMAP is for getting delivered mail, not sending mail. You don't need it.
If it's a Java web app, then the server part is a servlet. Given an email message sent from a client form, your server needs to send that text off as an email.
There's code in the Java EE stack to do this, or you can specifically download JavaMail. This will allow your programs to act as mail clients.
Your MTA receives messages from your servlet and sends them to the users. So far so good.
But you also need a postbox, i.e. the equivalent of a mail in-box for your users. Postfix, QMail and others offer a basic "flat" mailbox model, where mail is simply stored until the client picks it up, and then (usually) deleted. Access is via POP3. IMAP offers a lot more organizational capability, i.e. the ability to specify hierarchies of nested mailboxes, to transfer mails between them and so on. You probably won't want to create a GUI front end to all that complexity, so I'd guess you don't really need an IMAP server. You do, however, want a relatively simple POP3 server to allow your servlet to access the mailboxes via TCP/IP. This is usually part of the "standard" email server packages.
To have your own domain known to the world, you need access to the MX records of your DNS service, i.e. you have to set up one or two of your hosts, on an Internet-facing address, to be your post office.
Finally, if you want to save yourself a lot of trouble, be very careful in configuring your MTA (SMTP server) such that there is no chance for it being used as an open relay. i.e. it should not be possible for your users to send mail to the outside world in general (or hackers will find a way to abuse your Web interface to do this), and mail from the Internet should not reach your users. Most importantly, there should be no way for mail from the Internet to be forwarded to someplace else in the Internet. Find an open relay testing service (they're free) on the 'net and get one to run a test on your configuration once you think you're done.
EDIT:
Looking at Thorbjorn's answer, I realized you probably don't want your users receiving their mail through your app; they probably already have email providers and accounts of their own. In that case, you don't need to worry about inbox capability or a POP3 server. You could consider offering full email services at your domain but that's a very thankless job and if you have any choice, leave that dirty work to GMail, Yahoo, Hotmail and their ilk. Whatever service you provide will never please your customers enough, and you'll be fighting spam and other crime every day.
For starters your server has to have mailing abilities. In linux land sendmail is usually what this will be.
Additionally, check out javaMail.
http://www.oracle.com/technetwork/java/index-jsp-139225.html

Categories

Resources