Mail contains camel message headers
Issue
- We would like to use the mail component to send out mails to customers, for example when the processing of a file fails.
Because of that we have the following (simplified) route:
<route>
<from uri="file://{{Folder}}"></from>
<from uri="ftp://{{Configuration}}"></from>
<onException>
<exception>java.lang.Exception</exception>
<wireTap uri="direct:sendMail">
<body>
<simple>There was a problem saving ${header.CamelFileName}.</simple>
</body>
<setHeader headerName="Subject">
<constant>FATAL ERROR: Problem saving file ${header.CamelFileName}</constant>
</setHeader>
</wireTap>
</onException>
<!-- business logic with file ... -->
</route>
<route>
<from uri="direct:sendMail" ></from>
<to uri="smtp://{{.smtp.host}}:{{smtp.port}}?To={{email.errorTo}}&From={{email.errorFrom}}" ></to>
</route>
- The problem is that the Camel message headers are automatically printed in the email headers. Special case is also when one of the message headers contain a newline (for example
CamelFtpReplyString
when receiving files with ftp), the rest of the headers will be interpreted as email body.
CamelFileLastModified: 1421170020000
CamelFileLength: 10
CamelInterceptedEndpoint:
Message ID:
Content-Transfer-Encoding: 7bit
CamelFtpReplyString: 226 Transfer complete.
CamelFileName: testFtpFile.txt
CamelRedelivered: false
CamelRedeliveryCounter: 0
breadcrumbId: ID-localhost-34474-1421170062988-0-1
To: fakeTo@localhost
Content-Type: text/plain
CamelFileParent: /
CamelFilePath: /testFtpFile.txt
CamelFileHost: localhost
From: fakeFrom@localhost
CamelFileAbsolute: false
Date: Tue, 13 Jan 2015 22:57:45 +0530 (IST)
Subject: Problem saving file testFtpFile.txt
MIME-Version: 1.0
CamelFileNameConsumed: testFtpFile.txt
CamelFileRelativePath: testFtpFile.txt
CamelFileAbsolutePath: testFtpFile.txt
CamelFtpReplyCode: 226
CamelFileNameOnly: testFtpFile.txt
- We already tried to remove these headers with the use of
<removeHeaders pattern="*" excludePattern="CamelFileName" ></removeHeaders>
but then the CamelFileName
is still printed as email header.
- Using the wireTap copy="false", to create a new Exchange without the existing headers, will prevent the simple expression in the body and setHeader to resolve the CamelFileName and will also still print a breadcrumbId (of the new Exchange).
- Could you provide us a way to send out emails without Camel headers?
Environment
- Red hat JBoss Fuse
- 6.x
- Apache Camel
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.