Programmatically signing/encrypting Spring emails using GPG private-key - spring

I am trying to set up a service which needs to notify users via email from time to time using Java + Spring Boot 3.0.2.
I want the service to be able to search online public-key stores for a recipient and encrypt the message or if no public-key is found, simply sign the message with its own key.
I am using org.springframework.boot:spring-boot-starter-mail:3.0.2 and sending simple unencrypted/unsigned emails was up and running in no time using the org.springframework.mail.SimpleMailMessage type.
However, I cant seem to find any library or method of properly integrating GnuPG public-keys into sending emails. There is plenty of examples of using GPG for files, text etc. but how to use it for emails eludes me.
I have a working POC using the org.springframework.mail.SimpleMailMessage as message-type and org.springframework.mail.javamail.JavaMailSenderImpl for sending the email.
I have not found a library or a clear description of how to manually sign/encrypt mail-content, which is the root of this question.

Related

Spring Catch-All Email

I want to create a gallery app which is automatically feed by emails. When you register on the app I will provide an email pseudo#domain.com When you send a picture to this email you will receive a push notification and then fetch the image when the app will be open.
To do so, I think about an smtp server (like https://github.com/docker-mailserver/docker-mailserver) and a spring boot to listen all emails (via imap or pop). When an email is received, I will check the from to find the user concerned, save the image until the user open the app to fetch it.
I saw some lib to have an embedded smtp server in a spring boot app (https://github.com/voodoodyne/subethasmtp). But if I understand well it's only for testing.
I didn't find so much information and use case. So maybe I have a bad approach, and read all email from a domain is not a good practice. Do you have some documentation about this ?

Monitor sender's attachment (names only) with Gmail API or Mail Audit API (or with other APIs)?

I'm trying to create an app to monitor employee's file attachments using Google's APIs.
I know that I could download all the emails from the audited user list using Mail Audit API and run scripts on the mails but would there be a better way to get sender's email address with attached file names?
Unfortunately, the only options available are the ones you have already suggested.
However, what you can do is to file a feature request on Google's Issue Tracker here and provide all the necessary details about your use-case and what is it that you want to achieve.

How to read outlook email saved under local directory on pc using javax mail api

I am trying to read email saved to my localhost directory using javax mail api but I am not sure how to read from your local directory.
So I found third pary library which reads email for me and returns data in string format but not sure how to build javax mail message using those string data.
Problem trying to solve :
I want to read header from email which should be in key-value form. This comes only when you read from IMAP server.
Any help appreciated.
thank you
Happy Thanksgiving!!

Verified email in Spring Boot/Security registration

How to verify an email provided during registration is a real one? Confirmation link is an obvious choice, but I've seen websites where some kind of email verification happens right after you click 'register'. If email is fake, the process stops. How can this be done in Spring?
(example: safaribooksonline)
You have to check if the mail got bounced. If it does, it's not a valid email. You can use an api provided by neverbounce and here is the github link for that in java.
You can try the MailboxValidator API.
Just sign up for the free API key at https://www.mailboxvalidator.com/plans#api
Then you can use the Java code at https://github.com/MailboxValidator/mailboxvalidator-java or use Maven https://mvnrepository.com/artifact/com.mailboxvalidator/mailboxvalidator-java/1.0.0

How to send email from my website [duplicate]

This question already has answers here:
How do I send HTML email in Spring MVC?
(6 answers)
Closed 8 years ago.
I am developing a website/web appliaction. Now I have to send different emails to users, like after they register, or if they have any notification or if they forget their password and do password reset.
I will be hoisting it with some web hoisting website. I already had word with them and they will provide me with some email ids, like support#mywebsitename.com.
But I still have to write functionality to send email and I am not getting idea how exactly to go ahead with that. Almost all other things are done. I am passing email id, subject, message to the method. But how exactly to go ahead now.
Please help. I am using Spring MVC .
You need a SMTP server details which you get them from your provider to send an email from the application. And Using the Spring frame work it is quite easy to develop the mail functionality. Here is the Spring Mail where you get injection and code example. Before that you need to get some details from your service provider, like host name, port etc.
There is a simple and beautiful tutorial by mkyong on how to send Email via Spring Mail that I used: http://www.mkyong.com/spring/spring-sending-e-mail-via-gmail-smtp-server-with-mailsender/
Add JavaMail to your dependencies - configure the the mail settings in you spring-config once you have your credentials - create a MailService class where you use MailSender with SimpleMailMessage.

Resources