Don't require username on send mail routes (relays don't require login)
-----------------------------------------------------------------------
Key: CAMEL-1028
URL: https://issues.apache.org/activemq/browse/CAMEL-1028
Project: Apache Camel
Issue Type: Bug
Components: camel-mail
Affects Versions: 1.4.0
Reporter: David Peterson
Don't require a login in the send mail URI because internal relay mail servers
don't require them. If you do include one, the mail server gets confused and
thinks that you are looping and it will bounce the email so this is a bit
inconvenient bug.
e RuntimeCamelException (id=212)
cause FailedToCreateProducerException (id=215)
detailMessage "org.apache.camel.FailedToCreateProducerException:
Failed to create Producer for endpoint: Endpoint[smtp://mail.contextweb.corp].
Reason: java.lang.NullPointerException" (id=217)
stackTrace null
Stack Trace:
Thread [Thread: 1 [EMAIL PROTECTED] (Suspended)
AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(Exchange,
AsyncCallback) line: 45
SendProcessor.process(Exchange, AsyncCallback) line: 75
InstrumentationProcessor.process(Exchange, AsyncCallback) line: 57
DeadLetterChannel.process(Exchange, AsyncCallback,
DeadLetterChannel$RedeliveryData) line: 155
DeadLetterChannel.process(Exchange, AsyncCallback) line: 91
InstrumentationProcessor.process(Exchange, AsyncCallback) line: 57
UnitOfWorkProcessor.process(Exchange, AsyncCallback) line: 39
AsyncProcessorHelper.process(AsyncProcessor, Exchange) line: 41
UnitOfWorkProcessor(DelegateAsyncProcessor).process(Exchange) line: 66
MailConsumer.processMessage(Message) line: 169
MailConsumer.processMessages(Message[]) line: 151
MailConsumer.poll() line: 105
MailConsumer(ScheduledPollConsumer<E>).run() line: 65
Executors$RunnableAdapter<T>.call() line: 441
FutureTask$Sync.innerRunAndReset() line: 317
ScheduledThreadPoolExecutor$ScheduledFutureTask<V>(FutureTask<V>).runAndReset()
line: 150
ScheduledThreadPoolExecutor$ScheduledFutureTask<V>.access$101(ScheduledThreadPoolExecutor$ScheduledFutureTask)
line: 98
ScheduledThreadPoolExecutor$ScheduledFutureTask<V>.runPeriodic() line:
181
ScheduledThreadPoolExecutor$ScheduledFutureTask<V>.run() line: 205
ThreadPoolExecutor$Worker.runTask(Runnable) line: 885
ThreadPoolExecutor$Worker.run() line: 907
Thread.run() line: 619
Code:
AOPExceptionHandler:
private void sendEmail(String errors) {
template = camelContext.createProducerTemplate();
StringBuffer body = new StringBuffer("Hello Techops.\n");
body.append("Got an exception please handle.\n\nRegards
Reportdev.\n\n");
body.append(errors);
template.sendBodyAndHeaders(emailServerUri, body,
emailProperties);
}
applicationContext.xml
<bean id="logThrowsAdvice" class="com.contextweb.advice.LogEmailThrowsAdvice">
<property name="camelContext" ref="camel" />
<property name="sendMail" value="true" />
<!-- username=reportdev&[EMAIL PROTECTED] -->
<property name="emailServerUri"
value="smtp://mail.apache.corp" />
<property name="emailProperties">
<map>
<entry key="From">
<value>"[EMAIL PROTECTED]"</value>
</entry>
<entry key="Subject">
<value>"Exception in 3rd Party
Reporting Email
Processing"</value>
</entry>
<entry key="To">
<value>"[EMAIL PROTECTED]"</value>
</entry>
</map>
</property>
<property name="logFactory" ref="LogFactoryBean" />
</bean>
Workaround is to use URI for "To" and put the username after the ? in the URI.
This will fool the mail relay server into routing the email bypassing it's loop
detection logic:
<!-- Define the ThrowsAdvice bean -->
<bean id="logThrowsAdvice"
class="com.contextweb.advice.LogEmailThrowsAdvice">
<property name="camelContext" ref="camel" />
<property name="sendMail" value="true" />
<property name="emailServerUri"
value="smtp://mail.contextweb.corp?username=reportdev&[EMAIL PROTECTED]" />
<property name="emailProperties">
<map>
<entry key="From">
<value>"[EMAIL PROTECTED]"</value>
</entry>
<entry key="Subject">
<value>"Exception in 3rd Party
Reporting Email
Processing"</value>
</entry>
</map>
</property>
<property name="logFactory" ref="LogFactoryBean" />
</bean>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.