Nuñito Calzada
Nuñito Calzada

Reputation: 2056

Sending smtp emails with SpringBoot application

I have a basic SpringBoot 2.0.5.RELEASE app. Using Spring Initializer, JPA, embedded Tomcat, Thymeleaf template engine, and package as an executable JAR file.

I've configured the springboot properties as follows:

spring.mail.host=smtp.gmail.com
[email protected]
spring.mail.password=nunet999!
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
spring.mail.propertirs.mail.smtp.ssl.enable = true

and It is working fine when sending emails. I also have an email address from my domain [email protected]

I am using Postfix to forward the Emails from [email protected] to to [email protected] and its working fine.

I would like to know if there is a way to do it on the other way around. Send emails from [email protected] but using [email protected] smtp to avoid to install a Mail server.

or basically I would like to know how to extract the smtp properties from my linux server, because from there I can send emails using the command

cat ~/test_message | mail -s 'Test email subject line' [email protected]

Upvotes: 4

Views: 2132

Answers (2)

M-Razavi
M-Razavi

Reputation: 3467

I think you need Google Suite's email feature. With this feature You can create a custom email address using your own domain name then send & receive emails with Gmail (Gmail Suite).

After configuration working with Gmail's SMTP is same as you done before.

Read more: https://digital.com/blog/create-email-using-gmail/#ixzz5Sxusynvb

Upvotes: 1

benkuly
benkuly

Reputation: 1194

Basically this is possible with SMTP, but the most SMTP-Hoster don't allow it to avoid spammers to send spam. Furthermore the most E-Mail-Hoster will detected that kind of mails as spam.

Upvotes: 1

Related Questions