JSP Hosting

HostingServicesSupportOrderAbout UsSoftwareHome

Even experts read the manuals. Our tech support staff has most of the books that are out on a wide variety of web topics. Here are some of their top picks. We think you'll find them useful and informative as well.


Using JavaMail

The JavaMail API classes are included in the classpath for all accounts. JavaMail offers a simple, convenient interface for sending email from your web site forms and applications. The following code snippet can be used from servlets or JSPs for sending mail messages.

import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
try {
Properties props = new Properties();
props.put("mail.smtp.host", "localhost");
//NOTE: Session.getDefaultInstance may stop working under newer implementations
Session session = Session.getInstance(props, null);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("sender@sender.com"));
InternetAddress[] address = {new InternetAddress("recipient@recipient.com")};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject("Subject of message");
msg.setSentDate(new Date());
msg.setText("Body of message");
catch (javax.mail.MessagingException jmme) {

It is important that the recipient email address be a valid email address. If it is not, the email delivery may fail.

Before using JavaMail, please be aware of our Acceptable Use Policy regarding Unsolicited Commercial Email. Use of JavaMail for sending UCE or in violation of this policy will result in immediate account termination.


Note: MMA technical support staff cannot provide troubleshooting of problems with third-party CGI scripts including but not limited to: Perl scripts, C/C++ binaries, PHP or web/database integration unless these services are specifically contracted. For these services, please see our Quote Request Form.

Copyright © 1995-2012
Motivational Marketing Associates, LLC
All Rights Reserved.