|
Project Information
Links
|
******************************************************************************** ******************************************************************************** ******************************************************************************** This project moved to Github! Please go to http://github.com/guilhermechapiewski/fluent-mail-api to get the latest version and documentation. ******************************************************************************** ******************************************************************************** ******************************************************************************** AboutFluent Mail API is a simple Java API that uses Sun's JavaMail API to send e-mail messages. This is a project to demonstrate Fluent Interfaces usage. Usage examplenew EmailMessage()
.from("demo@guilhermechapiewski.com")
.to("destination@address.com")
.withSubject("Fluent Mail API")
.withBody("Demo message")
.send();Comparison to JavaMail APIIf you use pure JavaMail API, it will be something like this (from Java World tutorial): // create some properties and get the default Session
Properties props = new Properties();
props.put("mail.smtp.host", _smtpHost);
Session session = Session.getDefaultInstance(props, null);
// create a message
Address replyToList[] = { new InternetAddress(replyTo) };
Message newMessage = new MimeMessage(session);
if (_fromName != null)
newMessage.setFrom(new InternetAddress(from,
_fromName + " on behalf of " + replyTo));
else
newMessage.setFrom(new InternetAddress(from));
newMessage.setReplyTo(replyToList);
newMessage.setRecipients(Message.RecipientType.BCC, _toList);
newMessage.setSubject(subject);
newMessage.setSentDate(sentDate);
// send newMessage
Transport transport = session.getTransport(SMTP_MAIL);
transport.connect(_smtpHost, _user, _password);
transport.sendMessage(newMessage, _toList);20 second tutorialPlease go to http://github.com/guilhermechapiewski/fluent-mail-api to get the latest version and documentation. |