O'Reilly logo

Java™ Phrasebook by Timothy Fisher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sending Email

Properties props = new Properties( );
											props.put("mail.smtp.host", "mail.yourhost.com");
											Session session =
											Session.getDefaultInstance(props, null);
											Message msg = new MimeMessage(session);
											msg.setFrom(new
											InternetAddress("tim@timothyfisher.com"));
											InternetAddress toAddress =
											new InternetAddress("kerry@timothyfisher.com");
											msg.addRecipient(Message.RecipientType.TO,
											toAddress);
											msg.setSubject("Test Message");
											msg.setText("This is the body of my message.");
											Transport.send(msg);

In this phrase, we send a plaintext email message using an SMTP server. There are six basic steps that you should always follow when you want to send email using the JavaMail API. These steps are identified here:

1.
Create a java.util.Properties object, which ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required