Sending HTML emails with spring integration - html-email

I am using spring integration for a process which ends in an email being sent.
However, it is an HTML email and I receive the source for it, not the rendered HTML.
I have tried to use the mail header enricher provided with spring-integration-mail 2.1.4 to set the content type or activate multipart without result.
Can it be done with the mail header enricher or is it supposed to be configured in some other way?
A pure XML configuration preferable.

Yes you can send HTML via the XML configuration, you just need to set the content type as you said via the header enricher, example code below.
<int-mail:header-enricher id="emailheaderenricher">
<int-mail:content-type value="text/html;"/>
<int-mail:subject value="a subject"/>
<int-mail:to value="mail#somewhere.org"/>
<int-mail:from value="from#example.org"/>
</int-mail:header-enricher>

Related

Test email rendering - HTML raw source or HTML pre send?

I am testing some HTML email layout, I am not sure to understand which is the HTML I should consider:
use the HTML as it is sent from my server to mailgun (an email service provider)?
use the HTML as I receive it in raw format in the email I receive?
The difference is that in the raw source I receive there are =3D and =20 characters because of the quoted printable format. I'm using testi# but I suppose any rendering software will do, just it's not clear which version of the HTML should be used (needless to say I see =20 everywhere if it's raw, whereas it's perfect if I use the "pure" HTML)
You should use the HTML as it is before being sent. I'm unsure of how testi# works but with other services such as Litmus & Email on Acid you can send a test to them directly from your ESP and they will process that for the previews.
[Added from comment on question to allow close]

Am trying to implement Mail reader sampler. But i Am getting the reponse in Folder in the Response data in Jmeter

I am trying to extract an email using Mail Reader Sampler via Jmeter. But i am getting the response in this manner http://imgur.com/0FP2p7c
I am not understanding why it is happening....
Sometimes it happens when you switch View Results Tree listener mode between Text and HTML or XML. The solution is just to restart JMeter or add a new View Results Listener in "Text" mode.
As a workaround you can add Beanshell Listener with the following code:
log.info(sampleResult.getResponseDataAsString());
This way you will be able to see responses in either jmeter.log file or in log window by clicking yellow icon with exclamation sigh in upper-right corner of JMeter main frame:
See Load Testing Your Email Server: How to Send and Receive E-mails with JMeter for more details on testing outbound and inbound emails with JMeter

Resent headers in MIME email

I want to know more about the resent headers (resent-from, resent-to, resent-date etc) that get prepended to an email's header.
When do these headers get added? Do they get added by the server or the mail client program?
I need to write a Java program using JavaMail api to forward an email (without changing or parsing through it's original content). I would like the email to be redirected to the destination email address on arriving at the server for a specific recepient.
Any snippet where you have been able to forward / redirect a mime mail using the resent headers will be helpful.
Thank you
See section 3.6.6 of RFC 2822.
You should be able to use JavaMail to add these headers to a message. If the message was read from a folder on a mail server, you'll need to make a copy of the message first before you can change it. Use the MimeMessage copy constructor. You can then send it to whatever address you want, ignoring the addresses in the message, by using the Transport.send method that takes an array of addresses. If you need to preserve the original Message-ID (which may not be appropriate since you're modifying the message), you'll need to subclass MimeMessage and override the updateHeaders method.

Sending a URL/filePath in Resteasy request

I want to send path of a file alongwith some Strings.
After spending some time I was unable to find anything that can help. Could anyone suggest any link on how to do this on server side
You can use any of the following methods to submit a file path and some strings to the server:
Submit a Form with the file path and strings.
Encode the file path and send it as a query parameter in the URL along with the strings.
Create a message body containing the file path and other strings you want to send and submit it via a POST call.
Send the file path and strings in custom http headers.
Take a look at the Resteasy documentation here: http://docs.jboss.org/resteasy/docs/3.0.4.Final/userguide/html_single/
Pay special attention to the sections that talk about using the #Form, #FormParam, #QueryParam, and #POST annotations.

Add Request SOAP-Header to Response

I am working on an bottom up web service for axis2 deployed on tomcat.
The processing is all working, but for tracking purposes I would like to include some meta data using the Soap Header. Do you know how to make axis2 include the header received into the response? E.g. I would like to pass an id with the header and receive it with the response.
The way to handle these scenarios in Axis2 is to use a handler. You can engage your handler to the out flow and do the header adding part is there. This article[1] describes about the axis2 architecture and how to add new handlers using modules.
[1] http://wso2.org/library/articles/extending-axis2