[Beginners Corner] - javamail help: does it work with 4.04.ga?
by bezdomny
Has anyone gotten javamail to work?? I get ClassNotFoundExceptions when I uses mime/multipart messages and I get MessagingExceptions "can only send RFC822 compliant messages" when I just use something like the following code:
Session mailSession = null;
try {
Context ctx = new InitialContext();
//Context compEnv = (Context) ctx.lookup("java:comp/env");
//mailSession = (Session)compEnv.lookup("mail/AppMail");
Object objref = ctx.lookup("java:comp/env/mail/AppMail");
mailSession = (Session) PortableRemoteObject.narrow(objref, Session.class);
} catch (NamingException e) {
// TODO Auto-generated catch block
System.out.println(e);
e.printStackTrace();
}
InternetAddress[] address = new InternetAddress[to.length];
for(int i = 0; i < to.length; i++)
{
address = new InternetAddress(to );
}
// Define message
MimeMessage message = new MimeMessage(mailSession);
message.setFrom(new InternetAddress(from));
message.addRecipients(Message.RecipientType.TO,address);
message.setSubject("Hello JavaMail");
message.setText("Welcome to JavaMail");
// Send message
Transport.send(message);
Here is the debug output I'm seeing:
250-STARTTLS
250-8BITMIME
250-DSN
250 OVID
11:17:23,785 INFO [STDOUT] DEBUG SMTP: Found extension "STARTTLS", arg ""
11:17:23,785 INFO [STDOUT] DEBUG SMTP: Found extension "8BITMIME", arg ""
11:17:23,785 INFO [STDOUT] DEBUG SMTP: Found extension "DSN", arg ""
11:17:23,800 INFO [STDOUT] DEBUG SMTP: Found extension "OVID", arg ""
11:17:23,800 INFO [STDOUT] DEBUG SMTP: Can only send RFC822 msgs
11:17:23,800 INFO [STDOUT] QUIT
Here is my exception:
MessagingException:
SMTP can only send RFC822 messages
Also, I've tried sending through both windows and linux mail servers with the same luck.
Thanks!
B
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3976333#3976333
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3976333
19 years, 7 months
[Beginners Corner] - Problem with some attributes not being set in backingbean us
by mzachara
I'm not quite sure which component could be causing problems, but i'm using jboss 4.0.4 with bundled tomcat and jsf-myfaces implementation, so i guess others could have come across this as well...
I have a following scenario:
1) edit_company.jsp page with some h:inputText fields on submit,
2) a backing bean has several properties + setter/getter methods
3) backing bean performs some validation and returns control to the same edit_company.jsf page, displaying error messages (if any)
4) if there are no error messages, additional inputText is displayed for the user to supply his password to confirm changes
5) od submit, all previous data is sent to backing bean plus also the password submitted by user in the new field. Of course, the BB has setter/getter method for the password as well
now the problem is: if i display the inputText field at step (1), even if its empty and readonly - everything works fine. However, if i dont render this inputText at (1), but only at second stage (4), then on submit (5), the password is not transferred to the backing bean.
here is the relevant code of the jsp page:
<table>
| <tr>
| <td width="20%">Retailer UID: </td>
| <td width="50%">
| <h:inputText id="uid" size="20" dir="ltr" value="#{companyEdit.uid}" readonly="#{companyEdit.confirmState}" />
| </td>
| <td width="30%"><h:message styleClass="errorMsg" for="uid" /></td>
| </tr>
| <tr>
| <td>Name: </td>
| <td>
| <h:inputText id="nameE" size="40" dir="ltr" value="#{companyEdit.nameE}" readonly="#{companyEdit.confirmState}" />
| </td>
| <td><h:message styleClass="errorMsg" for="nameE" /></td>
| </tr>
| <tr>
| <td>Address: </td>
| <td>
| <h:inputTextarea id="address" rows="5" cols="40" dir="ltr" value="#{companyEdit.address}" readonly="#{companyEdit.confirmState}" />
| </td>
| <td><h:message styleClass="errorMsg" for="address" /></td>
| </tr>
| <tr>
| <td>
| <h:outputText dir="ltr" value="Enter your password:" rendered="#{companyEdit.confirmState}" />
| </td>
| <td>
| <h:inputText id="confirmPass" size="40" dir="ltr" value="#{companyEdit.pass}" rendered="#{companyEdit.entryState}" />
| </td>
| <td><h:message styleClass="errorMsg" for="confirmPass" /></td>
| </tr>
| <tr>
| <td colspan="3" align="center">
| <h:inputHidden value="#{companyEdit.confirmState}" id="confirmS" />
| <h:commandButton id="cancel" value="Cancel" action="#{companyEdit.cancel}" />
| <h:commandButton id="save" value="Save" action="#{companyEdit.save}" />
| </td>
| </tr>
| </table>
if i change:
<h:inputText id="confirmPass" size="40" dir="ltr" value="#{companyEdit.pass}" rendered="#{companyEdit.entryState}" />
to:
<h:inputText id="confirmPass" size="40" dir="ltr" value="#{companyEdit.pass}" readonly="#{companyEdit.entryState}" />
then everything works as expected. However without this component rendered doring the (1) phase, it doesnt work :(
the backing bean (managed bean) has scope: request
i've been wrestling with this for many hours now....
any help will be greatly appreciated
marek
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3976330#3976330
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3976330
19 years, 7 months