When I run my application locally, everything works correct, mails are sent, but I deployed my application to aws EC2 and I get this:
org.springframework.mail.MailAuthenticationException: Authentication failed;
I have less secure apps turned off on my gmail account I send emails from, the two steps verification is also turned off. As I said, everything was working before I deployed the app to aws.
Properties:
mail:
host: smtp.gmail.com
username: <my.mail>#gmail.com
password: <my.password>
port: 587
protocol: smtp
properties:
mail.smtps.auth: true
mail.smtp.starttls.enable: true
mail.smtp.ssl.trust: smtp.gmail.com
Am I missing any property or something like this?
This looks like duplicate from:
javax.mail.AuthenticationFailedException: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1
Ok, I finally solved this. The problem is that google blocks EC2 ports so what I needed to do was to turn on 2 steps verification in my google account -> then create new password (option under setting 2 steps verification) -> set this password in my .yml file as the new one -> everything works
I also set the SMTP rules in my EC2 security groups but I am not sure if it had any impact or the steps I have descripted above are enough
I have an existing Java Spring Boot project that been using Gmail for sending out email such as forgot password for our web system.
Recently we are moving to production as we are using Smartermail as our company email. The same Java Mail Code wrapper from Spring Boot that is working with Gmail SMTP is now not working after changing the configuration to smartermail SMTP.
However, I have tried to connect it from my Android phone email app using the same Smartermail configuration and credential, and it is all working.
Here is my application.properties content snapshot:
# Email setting
com.eurogain.portal.emailFrom=postmaster#myowndomain.com
spring.mail.host=mail.myowndomain.com
spring.mail.port=465
spring.mail.username=user1#myowndomain.com
spring.mail.password=password
spring.mail.properties.mail.smtp.connectiontimeout=15000
spring.mail.properties.mail.smtp.timeout=15000
spring.mail.properties.mail.smtp.writetimeout=15000
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
There are no error, and the above code the reason I put the timeout shorter is because without it, it will keep on running without any stop.
Any advise or tips? Appreciate the helps.
Ok, it was confirmed by the system admin that the port 465 here is for secure encryption type. The non-secure port is 587.
Still, in that case, does that mean Java Sprint Boot email doesn't support the secure type?
i've connected successfull to Azure Active Directory trough LDAP protocol with JAVA, i'm able to get users and their attributes.
I'm trying to change users's password but everytime i try to do it i receive this error from LDAP: "error code 50 - 00000005: SecErr: DSID-031A1256, problem 4003 (INSUFF_ACCESS_RIGHTS), data 0"
I've checked that the user and credential used for password reset have Administrative right (Global Administrator on Azure).
I've noticed that same problems appears when using LDAP GUI client: it's not possible to change user password because of insufficient right.
I'm struggling on how to do it but i've tried quite all things...
Have you got any suggestions?
Thank You
I am getting this error when I try to send mail using the JavaMail API:
javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted
How can I fix this?
Sorry for coming late to Party.These could be the problem in your task if you are using Gmail Server.
Two Step Verification should be turned off.
Allow Less Secure App(should be turned on).
Please Check Your UserName and Password.
Check the code(which was my Problem), Above three You can change form google help center and by Yourself last one My Experience I can Share with You.
You need to Authenticate the Mail server before Communicating the message because it is Challenge Response System By which You are Communicating through the mail.I am sharing code snippets file you can refer not able to format my code by ctrl+K.
This worked for me:
Login to the gmail account you are sending mail from
Go to Manage your Google Account -> Security -> Less secure app access -> Turn on access (not recommended)
or
Access the URL:
https://www.google.com/settings/security/lesssecureapps
Turn "Allow less secure apps: OFF" to "Allow less secure apps: ON"
Update:
Google stopped supporting "Less Secure Apps" as of May 30th, 2022.
One of the alternatives to solve this problem is to use 2-Step Verification and generate app password:
Google Account -> Security -> 2-Step Verification -> Input password as asked -> Turn ON (you could use SMS to get Gmail code to activate 2-Step Verification)
Google Account -> Security -> App password -> Input password as asked -> Select the app and device... -> e.g. Other(Custom name) -> Input app name e.g. MyApp -> Generate
Copy a 16-character password
Use a 16-character password with Gmail username in your application
Google support link here.
Update since June 2022:
Google closed the "Less secure app access",
but opened another option called "App Passwords":
"When you use 2-Step Verification, some less secure apps or devices may be blocked from accessing your Google Account. App Passwords are a way to let the blocked app or device access your Google Account." (see docs).
Follow this answer to set up App Passwords
Hint: when using Jenkins Email Extension Plugin, emailext (which does not permit tokens like Google's App Passwords, still requiring logins), just use App Password as the password, and supply any string as login, e.g. your Gmail address login.
OLD ANSWER , not relevant anymore
Step 1: Log into your gmail account
Step 2: Click Settings
Step 3: Click the Accounts and Import Tab > Other Google Account Settings
Step 4: Click Security
Scroll to the bottom of the page Under Less secure app access, click on Turn on access
Step 5: Set Allow less secure apps to ON
First of all make sure that all properties should be defined as follows:-
mail.smtp.host=smtp.gmail.com,
mail.smtp.port=25,
mail.smtp.auth=true
mail.smtp.starttls.enable=true
Now,make sure that two step verification is off
Allow less secure app (ON) follow this link :-
https://myaccount.google.com/lesssecureapps
Also, check your username and password is correct or not.
It works for me, you must configure your Gmail account with the below steps:
In the security section:
You need to Change "Allow less secure apps: OFF" to "Allow less secure apps: ON"
Log on gmail account, in Account ->
click Security -> turn off 2-step verification and turn on "Less secure app access"
May be because of things above, hope help you
I have the same error but when I run the app from the terminal, it goes away. My email configuration is provided:
spring.mail.host=smtp.googlemail.com
spring.mail.username=weddingcard9999#gmail.com
spring.mail.password=Weddingcard.1
spring.mail.port=587
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.required=true
Follow the steps:
Disable antivirus
Allow Less Secure App On
Two Step Verification should be turned off.
1.Allow Less Secure App(should be turned on).
2.Check Gmail Username and Password..
public static void main(String[] args) {
final String username = "YourMailId";
final String password = "password";
Properties prop = new Properties();
prop.put("mail.smtp.host", "smtp.gmail.com");
prop.put("mail.smtp.port", "587");
prop.put("mail.smtp.auth", "true");
prop.put("mail.smtp.starttls.enable", "true"); //TLS
Session session = Session.getInstance(prop,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("Tarunsunny143#gmail.com"));
message.setRecipients(
Message.RecipientType.TO,
InternetAddress.parse("balachandralucky2#gmail.com, to_username_b#yahoo.com")
);
message.setSubject("Testing Gmail TLS");
message.setText("Dear Mail Crawler,"
+ "\n\n Please do not spam my email!");
Transport.send(message);
System.out.println("Done");
} catch (MessagingException e) {
e.printStackTrace();
}
}
}
Please turn on by clicking the toggle button inside the google security panel.
Then it will allow less secured app also.
Change the settings in Google like this:
You probably got this error because the username and password of the from mail id is not matching. Please recheck your password and mail-id (username). It could be a typo.
In some cases, Gmail prevents logging in through external applications or programs which are not authorised.
Also login to your gmail account to check if gmail has prevented logging in to your account via your Java Mail API program.
If nothing works, you could try some other SMTP server (like yahoo, yandex).
For me works change the property "mail.host" recomended for #Heisenberg.
At documentation says to use "smtp.gmail.com" but works only I use "smtp.googlemail.com".
PS: My Allow Less Secure App configuration was already On
I had this issue while setting up my Jenkins and I resolved it without turning off my Two-Step Verification on my email account security.
This error in my case was because Two-Step Verification was enabled in my email, so I needed to add an app password to generate a password that will give Jenkins access to my mail in order to send emails on my behalf.
STEP 1: Click settings on your email account, select the "Account and Import" tab and in the change account settings, select "Other Google accounts settings"
STEP 2: In the settings screen that opens, select "Security" on the left-hand side, and under Signing in to Google, click "App passwords"
STEP 3: In the add passwords section, click the select app, and select "Mail"
STEP 4: Still in the add passwords, click on the select device and choose "Other (Custome name)".
And in the field that will show, enter a custom name for the app you are creating a password for and click the generate button.
FINALLY: Copy the generated password and use it as your email password while setting up email sending on Jenkins or any other app you are setting it up on.
I just hope this helps someone, give me a vote if it does, Thanks...
Google stopped supporting "Less Secure Apps" a time ago.
I used 2-Step Verification to generate app password and it worked for me:
Go to your Google Account -> Security -> 2-Step Verification
Then follow the steps to turn on
After that, go to your Google Account -> Security -> App passwords -> Select the app and device... -> e.g. Other(Custom name) -> Input app name e.g. Linux Computer -> Generate
Then copy the 16 character password shown in the screen and place it in the your applications config:
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=myappemailhere#gmail.com
spring.mail.password=mygeneratedpasswordhere
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
A couple of answers have mentioned the Less Secure App setting which google stopped supporting in May 2022. Just wanted to clarify that the May 2022 date concerns gmail accounts. If you use Google Workspace for your email, you can still access and enable the Less Secure App Access setting then proceed to use smtp.gmail.com via port 465 or 587.
The help text accompanying the setting says "Important: This deadline does not apply to Google Workspace or Google Cloud Identity customers. The enforcement date for these customers will be announced on the Workspace blog at a later date".
I am new in BIM Server , trying to figure out how BIM server and IFC model sync together.
I made connectivity to local BIM-server from a java application. I use the default settings as described in https://github.com/opensourceBIM/BIMserver/wiki/Setup .
Now, when I am going to create a new user it only ask for mail address , username and Access level. No password field . So, I can not do log in using that user.
"Send Password Reset" is giving the following error :
" Could not connect to SMTP host: localhost, port: 25 (java.net.ConnectException: Connection refused: connect) " .
Whether it is a BIM server version problem or I am missing something ?
I have not found any well prepared Documentation or tutorial on BIM server. My goal is to check how the BIM server can replace the ftp server that we are using now to store IFC files.
Thanks in advance
-Nazar-E-Bukhari
I have posted this in BIM server Issues. I am posting the answer if someone is also searching for the same solution.
"It's really bad practice to have an administrator set the user's passwords. How is the administrator going to give the passwords to those users? (I agree with him, but as because I am testing it in my localhost, I have no mail server configured)
Setup a working e-mail server, or better yet, use a third party's server. For example have a look at mailgun, sendgrid or postmark."