EJB-INTEREST:
I try to send email from the EJB by the jboss's Mail Session Service.
But the smtp service on the smtp.163.net need the user/passwd if you want to use
smtp.163.net to send email,
I have an account, but I don't know how to configure the JBOSS.
In the jboss.jcml
<mbean code="org.jboss.mail.MailService" name=":service=Mail">
<attribute name="JNDIName">Mail</attribute>
<attribute name="ConfigurationFile">mail.properties</attribute>
<attribute name="User">cm99</attribute>
<attribute name="Password">*******</attribute>
</mbean>
In the mail.properties
# Change to your mail server prototocol
mail.store.protocol = pop3
mail.transport.protocol = smtp
# Change to the user who will receive mail
mail.user = cm99
# Change to the mail server
mail.pop3.host = pop.163.net
# Change to the SMTP gateway server
mail.smtp.host = smtp.163.net
# Change to the address mail will be from
mail.from = [EMAIL PROTECTED]
# Enable debugging output from the javamail classes
mail.debug = false
In the MessageBean
Context initial = new InitialContext();
// look up the mail server session
javax.mail.Session session = (javax.mail.Session)
initial.lookup("java:comp/env/MailSession");
// Create a new mail object
javax.mail.Message msg = new MimeMessage(session);
// set various mail properties
msg.setFrom();
msg.setRecipients(javax.mail.Message.RecipientType.TO,
InternetAddress.parse(recipient, false));
msg.setSubject("Order Confirmation");
DateFormat dateFormatter = DateFormat.getDateTimeInstance(
DateFormat.LONG, DateFormat.SHORT);
Date timeStamp = new Date();
String messageText = "Thank you for your order." + '\n'
+ "We received your order on "
+ dateFormatter.format(timeStamp) + ".";
msg.setText(messageText);
msg.setSentDate(timeStamp);
// send the mail message
Transport.send(msg);
In the server.log
[02:20:02,330,Default] javax.ejb.EJBException: Sending failed;
nested exception is:
javax.mail.MessagingException: 553 You are not authorized to send mail as
<MAIL FROM:<[EMAIL PROTECTED]>>, authentication is required
[02:20:02,440,Default] at MessageBean.sendNote(MessageBean.java:92)
[02:20:02,440,Default] at MessageBean.onMessage(MessageBean.java:51)
[02:20:02,440,Default] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[02:20:02,500,Default] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[02:20:02,550,Default] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[02:20:02,610,Default] at java.lang.reflect.Method.invoke(Method.java:324)
[02:20:02,660,Default] at
org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:406)
[02:20:02,660,Default] at
org.jboss.ejb.plugins.MessageDrivenTxInterceptorBMT.invoke(MessageDrivenTxInterceptorBMT.java:81)
[02:20:02,720,Default] at
org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstanceInterceptor.java:81)
[02:20:02,720,Default] at
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:127)
[02:20:02,770,Default] at
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:170)
[02:20:02,770,Default] at
org.jboss.ejb.MessageDrivenContainer.invoke(MessageDrivenContainer.java:281)
[02:20:02,770,Default] at
org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:584)
[02:20:02,830,Default] at
org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSContainerInvoker.java:930)
[02:20:02,940,Default] at
org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:233)
[02:20:02,990,Default] at
org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:565)
[02:20:03,050,Default] at
org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:376)
[02:20:03,100,Default] at org.jboss.mq.SpySession.run(SpySession.java:248)
[02:20:03,160,Default] at
org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:172)
[02:20:03,210,Default] at
EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:725)
[02:20:03,270,Default] at java.lang.Thread.run(Thread.java:536)
David Chen
[EMAIL PROTECTED]
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".