SpringBoot Aruba Mail - spring-boot

I want to send a mail with Aruba host and SpringBoot 2.1.3 application. Before start I have done a little test, believing I would have found no problem.. I was wrong.
This is my application.properties
spring.mail.host=smtps.aruba.it
spring.mail.port=465
spring.mail.username=***
spring.mail.password=***
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.debug=true
Don't works, the debug says me that it cant connect to the hosts.. and, while it trying to do it, the debugger write:
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtps.aruba.it", port 465, isSSL false
What's wrong?? I trying to send mail with gmail and hotmail with the same parameters and all works well.. damned Aruba..
Thank you

Solution:
spring.mail.host=smtps.aruba.it
spring.mail.port=465
spring.mail.username=***
spring.mail.password=***
spring.mail.protocol=smtp
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.socketFactory.port=465
spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
spring.mail.properties.mail.smtp.socketFactory.fallback=false
Hope helps..

I'm not 100% sure about it but try to use as host smtp without "s" cause you are not using a secure SSL connection:
smtp.aruba.it
More informations : https://serversmtp.com/smtp-aruba/

If you want to use STARTTLS switch to port 587, port 465 is for implicit SSL not for explicit
spring.mail.host=smtps.aruba.it
spring.mail.port=587
spring.mail.username=***
spring.mail.password=***
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true

Related

XAMPP PHP - Send Mail

I wanna ask if my xampp version affects the sending of mail through xampp? I already configured php.ini and sendmail.ini
with
smtp port = 587 or 465
auth_password as my app password in my google account
It's not a problem now in the configuration now that this error already disappeared:
mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()
What is the problem now?

Spring Boot HTTPS on localhost

I had this working on localhost about a month ago, but when I came back to the project, hitting the URL results in a "This site can’t provide a secure connection" error in the browser. For reference, I believe I had used this site as a guide to get it set up: https://www.thomasvitale.com/https-spring-boot-ssl-certificate/
I'm running the project with the bootRun Gradle task and the default embedded Tomcat server. The following configuration is set:
/grails-app/conf/application.yml
spring:
profiles: development
server:
port: 8092
ssl:
enabled: true
key-store: classpath:keystore.jks
key-store-password: password
key-store-type: pkcs12
key-alias: alias
key-password: password
The keystore is located at /src/main/resources/keystore.jks.
I don't see any errors in the console indicating any issues opening or accessing the keystore so I'm at a loss as to what might have changed. Is there a better guide than the one linked above that would give me other things to check for issues?
Eventually, I tried changing the password field to something I knew was not the password and the app started without errors. This led me to determine that the YAML file was not being picked up by bootRun. Removing the Spring profile config at the top of the YAML file then caused the app to error because of the incorrect password.
This led me to realize that somehow the active profile configuration in my Gradle bootRun task was reset. Adding -Dspring.profiles.active=development to the VM options fixes the problem.

How to disable authentication while testing email service using greenmail

I have written an email service using Spring Email and then used Greenmail to test the email service. But while running the test case it gives an error Authentication failed as below:
javax.mail.AuthenticationFailedException: 535 5.7.0 Authentication credentials invalid at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:965)
at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:876)
How can this error be resolved without giving my username/password in the code. Note that I have also tried giving username/password but it failed with the same exception. Thanks for any help.
greenMail = new GreenMail(new ServerSetup(2525, "127.0.0.1", "smtp"));
greenMail.setUser("username", "secret");
When Setting up your greenmail instance for testing you need to use the setUser and enter
username and password above and then add the properties specified in the #One Guy post above this. has worked for me after I received the Authentication credentials invalid Exception.
Hope this helps anyone facing a the issue
See AuthenticationDisabledTest.java how to configure a GreenMail junit test using disabled authentication.
Looks like you don't added the mock credentials i.e. a a resource file called application-test.yml file which is located in the src/test/resources folder.
application.yml
spring:
mail:
default-encoding: UTF-8
host: localhost
jndi-name:
username: username
password: secret
port: 2525
properties:
mail:
debug: false
smtp:
debug: false
auth: true
starttls: true
protocol: smtp
test-connection: false
You can take a look an example by following link:
https://memorynotfound.com/spring-mail-integration-testing-junit-greenmail-example/

Connection refused to host: smtp.gmail.com port: 587 from Spring Boot

I am trying to send email using spring-boot-starter-mail and the result is
Failed message 1: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 587; timeout 5000;
My application.properties are
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=<email>
spring.mail.password=<password>
# Other properties
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.connectiontimeout=5000
spring.mail.properties.mail.smtp.timeout=5000
spring.mail.properties.mail.smtp.writetimeout=5000
# TLS , port 587
spring.mail.properties.mail.smtp.ssl.trust=smtp.gmail.com
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.smtp.starttls.enable=true
I have tried myriad combinations and all roads lead to this same exception! I can telnet to smtp.gmail.com 587 and receive a response
220 smtp.gmail.com ESMTP e82sm2105370oia.36 - gsmtp
Many links I followed suggested a firewall might be to blame. Has anyone seen this issue?
Are you using a proxy? If your telnet is successful then it’s using some configuration that your spring application lacks, perhaps an environment variable such as HTTP_PROXY is set? The most likely scenario I come across in this situation is this issue. You would them need to set this as normal for any java application by passing the
-Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=3128
arguments.

Expected response code 220 but got code "500" when sending mail in Laravel 5.4 in local environment

I'm migrating a Laravel 5.0 app to 5.4 and am trying to test the mail in my local environment. I've always used Anitix SMTP Imposter for this. Here's what my mail configuration looks like in my .env:
MAIL_DRIVER=smtp
MAIL_HOST=127.0.0.1
MAIL_PORT=25
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPT=null
This has always worked in all previous versions of Laravel (4, 4.2, 5.0), but suddenly with 5.4 I'm getting the following error:
Swift_TransportException in AbstractSmtpTransport.php line 383:
Expected response code 220 but got code "500", with message "500 Command not recognized
"
I've tried disabling Avast, using alternative programs like Papercut, playing with the config by using SSL or TLS, but I can't figure out what's causing this. Any ideas?
Late answer, but I came here myself running into the same issue.
MailHog does not support TLS encryption. Adding MAIL_ENCRYPTION=null to my .env file fixed my issue.
First try: php artisan config:cache and restart your local server, perhaps Laravel use the old mail data.
For development purpose https://mailtrap.io/ provides you with all the settings that needs to be added in .env file. Eg:
Host: mailtrap.io
Port: 25 or 465 or 2525
Username: cb1d1475bc6cce
Password: 7a330479c15f99
Auth: PLAIN, LOGIN and CRAM-MD5
TLS: Optional
Otherwise for implementation purpose you can get the smtp credentials to be added in .env file from the mail (like gmail n all)
After addition make sure to restart the server
You can use https://mailtrap.io/
it will provide you all necessary details for you to check mail functions in your local machine including username,password,port,host,etc.
if still have same issue issue,
use these details in config/mail.php file in your project instead of using .env file.
return array(
"driver" => "smtp",
"host" => "mailtrap.io",
"port" => 2525,
"username" => "mailtrap.io_your_username",
"password" => "mailtrap.io_your_password",
"sendmail" => "/usr/sbin/sendmail -bs",
"pretend" => false
);
it is work for me.
MAIL_DRIVER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=null
I am use a mailhog docker container.
mailhog:
image: mailhog/mailhog:v1.0.0
ports:
- "1025:1025" // smtp
- "8025:8025" // web

Resources