How to send email from my website [duplicate] - spring

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.

Related

Programmatically signing/encrypting Spring emails using GPG private-key

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.

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 ?

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 transfer my domain from bluehost, enable email notification and receive emails?

This is sort of planning question . I have my domain at bluehost.com. But since I started to learn laravel and I am currently having temp domain in hover and I have forge/digitalocean solution.. Now I want to pull my real domain and make some email inboxes for my team.. how can I achieve that.. what tools I need to use.. my question has three parts :
1- How to pull my old domain from bluehost to forge/digitalocea, ? 2- How to create email for my team such as support#mydomain.com .. admin#mydomain.com and I want to get emails from outside world 3- How can I send email notifications from my project such as ,, account confirmation.. etc? ( I tried mailgun but it seems it not stable. it failed sometimes to send and sometimes there is delay ).
Please advice!!
How to pull my old domain from bluehost to forge/digitalocean?
Please refer on this link: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-host-name-with-digitalocean
Or see an example here: http://bivori.com/migration-form-bluehost-to-digitalocean/
How to create an email server?
You can use and integrate Zoho Mail Server for Free upto 25 users.
Just follow this link:
https://www.digitalocean.com/community/tutorials/how-to-set-up-zoho-mail-with-a-custom-domain-managed-by-digitalocean-dns
How can I process email messaging?
If your using Laravel, I suggest you follow instructions as stated in their manual:
https://laravel.com/docs/5.3/mail

Is it possible to send an e-mail using the VS2010 development server?

Is it possible to send an e-mail using the VS2010 development server? If that's possible, can someone point me to a sample the web?
I'd like to send an e-mail to the person who register so to keep a proof that we (yes or not) received his request. The e-mail will contains a few pertinent info, such as the name, time, and son on.
EDIT
At my work, we collect data and to whoever needs as long as the ministry we work for tells as to do so. After we receive the paper form, we write an e-mail to the form sender. Until now, we use a paper form to know who needs data. I'd like to put that form online and also be able to generate an e-mail to the sender of the request. So, since I'm still developing the application, I need to test how sending the e-mail will work. That's why I'm asking if I can send an e-mail, for instance, to my Yahoo account from my laptop using VS2008 web development server.
I remember, 2 years ago, while learning HTML with DreamWeaver, we where able to send e-mail and received them in our Yahoo e-mail accounts (without any special configuration).
Thanks for helping
The web server won't make a difference. Whether you can will depend on the environment your server is in.
The simplest option is to use .NET's built-in email classes. You're probably using .NET 3.5 so that's System.Net.Mail, e.g.
MailMessage message = new MailMessage()
{
From = new MailAddress("you#youraddress", "Your Name"),
Subject = "The subject",
Body = #"Simple text body; set IsBodyHtml for HTML"
};
message.To.Add(new MailAddress("first#recipient.address", "First recipient - can add more"));
SmtpClient smtpClient = new SmtpClient("your.smtp.server");
smtpClient.Send(message);
If you don't specify an SMTP server name in the constructor it will read it from web.config.
If you don't have access to an SMTP server but do have permission to use external web services then you could use something like http://postmarkapp.com/ - I've seen other questions about them here but haven't used them myself.
Not answering straight to the question, but:
If testing the emails sent when running on a development server is the purpose, a simple SMTP stub server like smtp4dev is a good alternative?

Resources