Write a Java program that uses a java mail API that sends an encrypted email from google mail using TLS and giving the MAIL FROM, MAIL TO, SUBJ, and message
For this program, we need to keep the following things into our mind.
For running the below program, you need to have javax-mail jar file set up properly and then you need to change the value of email and pass in the program and then you need to set the value of to_email to the email where you want to send this test message and last you just need to remove spcae present between "i" and "l" in the code below, I am highlighting it at that place.
You may need to change some settings in your google account, I took these from google website. Its just a single step.
Following is the program.
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class Email {
public static void main(String[] args) {
// Set your own google address here
final String email = "your_email";
// Set an email to which you want to send email to
final String to_email = "to_email";
// writing your password here
final String pass = "password";
// Getting the properties of system
Properties props = new Properties();
// here we need to enable the authentification using email and password
props.put("mail.smtp.auth", "true");
// As we are using TLS, we need to turn it on.
props.put("mail.smtp.starttls.enable", "true");
// we need to set up the properties object and remove the space between "i" and "l"
props.put("mail.smtp.host", "smtp.gmai l.com");
// setting the port used by SMTP for sending email
props.put("mail.smtp.port", "587");
// Creating a session
Session session = Session.getInstance(props,
new javax.mail.Authenticator() {
//override the getPasswordAuthentication method
protected PasswordAuthentication
getPasswordAuthentication() {
return new PasswordAuthentication(email,
pass);
}
});
try {
// making a new Message class object to fill in the details of message content
Message message = new MimeMessage(session);
// setting the MAIL from in the content of email
message.setFrom(new InternetAddress(email));
// now setting the receipients, basically means the MAIL TO:
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(to_email));
// Adding the subject to the email
message.setSubject("TEST EMAIL");
// adding the text of the email
message.setText("email has been sent");
// this Transport static method send will send the message.
Transport.send(message);
// printing the success message.
System.out.println("Message has been sent");
} catch (MessagingException e) {
// handling the exception.
throw new RuntimeException(e);
}
}
}
![l Problems Javadoc Declaration ConsoleProperties kterminated> Email |Java Application] CAProgram FilesJavaljrel8.0 171 bin\javaw.exe (Dec 2, 2018, 1:26:12 AM Message has been sent](http://img.homeworklib.com/questions/a72b8070-fd46-11eb-975b-bfa643bd5b86.png?x-oss-process=image/resize,w_560)
If you have any problem regarding the solution to the problem, do let me know in the comment section below.
Don't forget to like the solution, it really means a lot.
Cheers!
Write a Java program that uses a java mail API that sends an encrypted email from...
SMTP Your task is to develop a simple mail client that sends email to any recipient. Your client will need to connect to a mail server, dialogue with the mail server using the SMTP protocol, and send an email message to the mail server. Python provides a module, called smtplib, which has built in methods to send mail using SMTP protocol. However, we will not be using this module in this lab, because it hide the details of SMTP and...
When using the Java mail API, the MessagingException is often caught in the catch block rather than other Java exceptions that are related to the use of the Java mail API. Why is this?
In java write a command-line program that helps to decrypt a message that has been encrypted using a Caesar cipher1. Using this method, a string may contain letters, numbers, and other ASCII characters, but only the letters (upper- and lower-case) are encrypted – a constant number, the shift, is added to the ASCII value of each letter and when letters are shifted beyond ‘z’ or ‘Z’ they are wrapped around (e.g. “Crazy?” becomes “Etcba?” when shifted by 2). When your...
Write a javascript program that downloads data from an API and displays it on a graph. Use a government API. I recommend using jsfiddle or other online editor.
Please write in Java in Jgrasp check code before posting Please
write in Java in Jgrasp check code before posting
Please write in Java in Jgrasp check code before posting, will
give thumbs up
FOP- 2. Write a program that ciphers a plain text message using double transposition scheme and vice versa. [50 Marks) The program should accept five tuples of input: plain text, row, column, permutation of row and columns. An example of encrypted text for the plain text...
Java program please
Exercise 7.2.8: Using the charAt) method, write and run a Java program that rea tring and prints the string in reverse order. (Tip: Once the string has been entere aved, retrieve and display characters starting from the end of the string). Write a Java program that has 3 buttons. Clicking the first button shows the message "See no evil", clicking the second button shows the message "Hear no evil", clicking the third button shows the message "Speak...
How do I write a java code that mimics charAt without using java API just primitives and no charAt to be used? I know it comes from primitives but I am confused on how to assemble the loops to derive my own charAt code
Write a Java program which uses a for loop to sum all the even numbers from 1 to 30.
Need some help with this UNIX problem: Write a single line UNIX command to mail only the process ID of running Java program test to the email test@fsu.edu
Python: •Write a program to get the Food Menu using an API •The program should be able to display different food items. If possible, add food prices .