tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Willart" <patr...@aptitudexchange.com>
Subject RE: Javamail not working with non-Outlook Express users.
Date Thu, 15 Jan 2004 00:17:59 GMT
When I read your problem description, the first thing I think of is that the
format of your mail message is not correct. Outlook Express might not be so
strict and render your mail message without any problems while other email
clients require a proper formatted email.

grts,

Patrick

-----Original Message-----
From: charles doweary [mailto:charlesdoweary@hotmail.com]
Sent: Wednesday, January 14, 2004 3:59 PM
To: tomcat-user@jakarta.apache.org
Cc: charlesdoweary@hotmail.com
Subject: Javamail not working with non-Outlook Express users.


System setup:  Windows Server 2003, Tomcat5.0.16, and IIS6.0.

My mail server sends email messages successfully when the user has Outlook
Express set up on their desktop, but non-Outlook Express users get the
following servlet error messages:

HTTP Status 500 - type Exception report

message description:  The server encountered an internal error () that
prevented it from fulfilling this request.

exception javax.servlet.ServletException

org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextI
mpl.java:867)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:800)
org.apache.jsp.jsp.authorizePurchase_jsp._jspService(authorizePurchase_jsp.j
ava:204)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
             javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
11)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
             javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

root cause
com.generic.exceptions.CustomerActivityException
             com.generic.product.Order.recordOrder(Unknown Source)

org.apache.jsp.jsp.authorizePurchase_jsp._jspService(authorizePurchase_jsp.j
ava:151)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
             javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
11)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
             javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

note The full stack trace of the root cause is available in the Tomcat logs.

Apache Tomcat/5.0.16

Here is a copy of the source code that is used to send the email message:

package com.generic.product;

import java.util.Vector;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Properties;
import java.text.NumberFormat;
import java.sql.*;
import org.apache.log4j.Category;
import org.apache.turbine.services.db.TurbineDB;
import org.apache.turbine.util.db.pool.DBConnection;
import com.generic.product.Product;
import java.util.ResourceBundle;
import com.generic.customer.*;
import com.generic.product.*;
import com.generic.exceptions.*;
import com.generic.cart.*;
import javax.naming.NamingException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingEnumeration;
import javax.naming.directory.InitialDirContext;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.AddressException;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.MessagingException;
import javax.mail.Transport;
import javax.servlet.http.*;
import com.braju.format.*;

public class Order {
    private static ResourceBundle sql_bundle =
	ResourceBundle.getBundle("com.generic.product.SQLQueries");

    private static ResourceBundle email_bundle =
	ResourceBundle.getBundle("com.generic.emailProperties");

/**
     * Mails a receipt for the order to the customer.
     *
     * @param email The address to mail the receipt to.
     **/

    public void emailReceipt(String email)
	throws NamingException, AddressException, MessagingException {
	Properties props = new Properties();
                props.put("smtp.covad.net", "XXXXXX-YYYYYY1");
	Session session = Session.getDefaultInstance(props, null);

	Message message = new MimeMessage(session);
	message.setFrom(new InternetAddress(email_bundle.getString("fromAddr")));
	InternetAddress to[] = new InternetAddress[1];
	to[0] = new InternetAddress(email);
	message.setRecipients(Message.RecipientType.TO, to);
	message.setSubject("Receipt for order " + getOrderNumber());
	StringBuffer contents = new StringBuffer();
	contents.append("Thank you for shopping at Generic Books.\n\n");
	contents.append("Here is the receipt for your order " + getOrderNumber() +
			" placed on " + getOrderDate() + "\n\n");
	contents.append("CODE        TITLE                           QUANT  PRICE
TOTAL\n");

contents.append("===========================================================
=====\n");
	Iterator items = getItems().iterator();
	while (items.hasNext()) {
	    CartItem it = (CartItem) items.next();
	    Parameters p = new Parameters();
	    p.add(it.getProduct().getPRODUCT_ID());
	    p.add(it.getProduct().getTitle());
	    p.add(it.getQuantity());
	    p.add(it.getProduct().getPrice());
	    p.add(it.getLineItemPrice());
	    contents.append(Format.sprintf("%-10.10s  %-30.30s  %2d     $%5.2f
$%5.2f\n", p));
	}
	message.setContent(contents.toString(), "text/plain");
	Transport.send(message);
    }

}

Questions:

   1.  My mail server permits messages to be relayed, and the email messages
do work with Outlook Express.  What do I need to add/change in the above
code to get the messaging to work in all cases?

   2.   Does JavaMail only work with Outlook Express?

   3.   Is there some additional software that I need to be using to get
JavaMail to work in all cases?

Please advise,
Thanks

_________________________________________________________________
Get a FREE online virus check for your PC here, from McAfee.
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message