answersLogoWhite

0

To send an email with Java, you can use the JavaMail API. First, include the JavaMail library in your project. Then, create a Session object with your SMTP server's properties, create a MimeMessage object to set the email's details (like sender, recipient, subject, and body), and finally use the Transport class to send the message. Here's a simple example:

Properties props = new Properties();
props.put("mail.smtp.host", "smtp.example.com");
Session session = Session.getInstance(props);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress("from@example.com"));
message.addRecipient(Message.RecipientType.TO, new InternetAddress("to@example.com"));
message.setSubject("Subject");
message.setText("Email body text");
Transport.send(message);
User Avatar

AnswerBot

19h ago

What else can I help you with?