-
1. Re: Seam mail does MIME message correct, but doens't send subject
kapitanpetko Sep 9, 2009 6:46 AM (in response to bobthule)Maybe you need to post some code, so that someone can see what you are doing wrong.
What do you mean by 'the debug'? Did you turn Java mail debugging on?
You could set breakpoints in UIMessage.encodeEnd to see how your message
looks like before being sent. -
2. Re: Seam mail does MIME message correct, but doens't send subject
bobthule Sep 9, 2009 4:30 PM (in response to bobthule)I am not sure what all you feel is relevant and needed. The code to call the render is simply:
Renderer.render('/email.xhtml');
well, in the unit test it is called in a block like this:
new FacesRequest() { @Override protected void invokeApplication() throws Exception { Renderer.instance().render("/WEB-INF/email/Test.xhtml"); } }.run();
The email.xhtml is
<m:message xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://jboss.com/products/seam/pdf" xmlns:m="http://jboss.com/products/seam/mail"> <m:from address="me@host.com" /> <m:to address="friend@host.com" /> <m:subject>Testing email send</m:subject> <m:attachment fileName="tiny.pdf"> <p:document> A very tiny PDF </p:document> </m:attachment> <m:body> <html> <body> Test body. </body> </html> </m:body> </m:message>
I turn debugging on in the mailSession setup in components.xhtml:
<mail:mail-session installed="true" host="host.com" port="25" tls="false" debug="true"/>
The output I get from the unit test is:
EHLO MYPC 250-host.com 250-PIPELINING 250-SIZE 104857600 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN DEBUG SMTP: Found extension "PIPELINING", arg "" DEBUG SMTP: Found extension "SIZE", arg "104857600" DEBUG SMTP: Found extension "STARTTLS", arg "" DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg "" DEBUG SMTP: Found extension "8BITMIME", arg "" DEBUG SMTP: Found extension "DSN", arg "" DEBUG SMTP: use8bit false MAIL FROM:<me@host.com> 250 2.1.0 Ok RCPT TO:<friend@host.com> 250 2.1.5 Ok DEBUG SMTP: Verified Addresses DEBUG SMTP: friend@host.com DATA 354 End data with <CR><LF>.<CR><LF> From: me@host.com To: friend@host.com Message-ID: <8254508.01252505792802.JavaMail.friend@MYPC> Subject: Testing email send MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_0_13289591.1252505792583" ------=_Part_0_13289591.1252505792583 Content-Type: multipart/related; boundary="----=_Part_1_553984.1252505792739" ------=_Part_1_553984.1252505792739 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline Test body. ------=_Part_1_553984.1252505792739 Content-Type: text/html; charset=us-ascii; name=tiny.pdf Content-Transfer-Encoding: 7bit Content-ID: <cafpevyzyabthbttmgbd> Content-Disposition: attachment; filename=tiny.pdf A very tiny PDF ------=_Part_1_553984.1252505792739-- ------=_Part_0_13289591.1252505792583-- . 250 2.0.0 Ok: queued as 4A87520028 QUIT 221 2.0.0 Bye
The output I get from the web test is:
EHLO MYPC 250-host.com 250-PIPELINING 250-SIZE 104857600 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN DEBUG SMTP: Found extension "PIPELINING", arg "" DEBUG SMTP: Found extension "SIZE", arg "104857600" DEBUG SMTP: Found extension "STARTTLS", arg "" DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg "" DEBUG SMTP: Found extension "8BITMIME", arg "" DEBUG SMTP: Found extension "DSN", arg "" DEBUG SMTP: use8bit false MAIL FROM:<me@host.com> 250 2.1.0 Ok RCPT TO:<friend@host.com> 250 2.1.5 Ok DEBUG SMTP: Verified Addresses DEBUG SMTP: friend@host.com DATA 354 End data with <CR><LF>.<CR><LF> ------=_Part_0_22502526.1252505524719 Content-Type: multipart/related; boundary="----=_Part_1_21044016.1252505525733" ------=_Part_1_21044016.1252505525733 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline <html> <body> Test body. </body> </html> ------=_Part_1_21044016.1252505525733 Content-Type: text/plain; name=tiny.pdf Content-Transfer-Encoding: base64 Content-ID: <uotrougdddesqgnxhdmy> Content-Disposition: attachment; filename=tiny.pdf JVBERi0xLjQKJeLjz9MKMi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wMjZi ZTlmY2YwYjhlNWI5ZTRkYWFhOGNmPjwwYTE3OWRlMTY4NmZlNTA4YTMyZDlmYmJkMjdkYjEzYz5d L1Jvb3QgNSAwIFIvU2l6ZSA3L0luZm8gNiAwIFI+PgpzdGFydHhyZWYKNjIyCiUlRU9GCg== ------=_Part_1_21044016.1252505525733-- ------=_Part_0_22502526.1252505524719-- . 250 2.0.0 Ok: queued as 3F26F154009 QUIT 221 2.0.0 Bye
-
3. Re: Seam mail does MIME message correct, but doens't send subject
bobthule Sep 9, 2009 4:34 PM (in response to bobthule)sorry
the code to call the render is simply:
Renderer.instance().render('/email.xhtml');
The unit test is called in a block like this:
new FacesRequest() { @Override protected void invokeApplication() throws Exception { Renderer.instance().render("/email.xhtml"); } }.run();
-
4. Re: Seam mail does MIME message correct, but doens't send subject
bobthule Sep 9, 2009 9:59 PM (in response to bobthule)I figured out the fix for the website:
Both Sun's JavaMail/Activation and Geronimo's JavaMail/Activation were on the classpath. The Geronimo was an older version brought in by Maven2 to satisfy Axiom dependencies. I removed the Sun libraries and specified to use the newer Geronimo libraries.But, I still don't have the unit test working. I am not sure where to begin trying to solve this. I am copying all the web-app related folders to a webapp directory and adding that to the classpath. Facelets looks like it is showing the same TagLibraryConfig loadImplicit INFO lines in the unit test as it is in the web.
How do I go about figuring out why the tags inside
<m:attachment fileName="tiny.pdf">
and
<m:body>
are being ignored?
-
5. Re: Seam mail does MIME message correct, but doens't send subject
kapitanpetko Sep 11, 2009 4:42 AM (in response to bobthule)How are you verifying your test is successful? By looking at actual message you receive?
Seam provides a MockTransport, so you can test if your message is correctly constructed,
without actually sending it. It is in the docs, but basically:MimeMessage renderedMessage = getRenderedMailMessage("/mail.xhtml"); assert renderedMessage.getAllRecipients().length == 1; InternetAddress to = (InternetAddress) renderedMessage.getAllRecipients()[0]; assert to.getAddress().equals("test@foo.com");
What this does is save the message in application scope instead of sending it,
and returns is as is. You can than check for headers, subject, content, etc.HTH
-
6. Re: Seam mail does MIME message correct, but doens't send subject
domjoel Sep 11, 2009 3:29 PM (in response to bobthule)Click HELP for text formatting instructions. Then edit this text and check the preview.
Thank you for this..I will surely take note of this..
-
7. Re: Seam mail does MIME message correct, but doens't send subject
bobthule Oct 2, 2009 9:33 PM (in response to bobthule)Hi Nikolay,
Sorry for the long delay in answering. Right, the code block you sent is closer to my end goal. although the way I am finding the problem is by viewing the debug output when the mail-session debug is
true
(and by receiving the badly formatted email). The code and output I listed above shows that when the email is creating from running from the website, that the MimeMessage is rendered correctly-- but when it is run through the unit tests, that MimeMessage drops all the tags within the m:attachment and m:body tags.