/ Published in: Java
Simple Mail Example.
Tags: SMTP, Mail, Java
[JavaMail (Sun)](http://java.sun.com/products/javamail/)
[JavaMail (Galileo)](http://openbook.galileocomputing.de/javainsel8/javainsel_18_012.htm#mj2a4110a634c82a3f676d8f87a50d6567)
Tags: SMTP, Mail, Java
[JavaMail (Sun)](http://java.sun.com/products/javamail/)
[JavaMail (Galileo)](http://openbook.galileocomputing.de/javainsel8/javainsel_18_012.htm#mj2a4110a634c82a3f676d8f87a50d6567)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import java.util.*; import javax.mail.*; import javax.mail.internet.*; public class JavaMail { String subject, throws MessagingException { props.put( "mail.smtp.host", "mySMTPHost" ); props.put( "mail.smtp.auth","true"); } }; Session session = Session.getDefaultInstance( props , authenticator); Message msg = new MimeMessage( session ); InternetAddress addressFrom = new InternetAddress( from ); msg.setFrom( addressFrom ); InternetAddress addressTo = new InternetAddress( recipient ); msg.setRecipient( Message.RecipientType.TO, addressTo ); msg.setSubject( subject ); msg.setContent( message, "text/plain" ); Transport.send( msg ); } { postMail( "[email protected]", "mySubject", "myContent", } }