You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "John.R.Moore" <jo...@kronos.com> on 2012/12/24 19:11:11 UTC

How To Get The SMTP Message-ID

I have a system where I need to record the SMTP Message-ID for every sent
message and use to correlate back responses.   I followed the simple sending
via SMTP examples from http://camel.apache.org/mail.html and had hoped to
find the returned reference somewhere in the exchange to no avail.   

Is the message-id available in the exchange and I'm just not finding it or
do I need to handle the sending of the SMTP message myself and push into the
exchange.out?

Thanks in advance,
John

		<route id="sendToMail">
			<from uri="direct:toSMTP"/>
			<pipeline>
				<to
uri="smtps://smtp.mail.**********.com?username=johnmoore330@ymail.com&amp;password=**********&amp;to=******@*****.com&amp;from=*******@*****.com&amp;subject=offers"
/>
				<process  ref="dummyProcessor" />
			</pipeline>
			<to uri="mock:sentmail"/>
		</route>



	@Test
	public void testSmtpSend() throws Exception {

		assertEquals(ServiceStatus.Started, context.getStatus());

		Exchange exchange = sendMail.createExchange();
		Message in = exchange.getIn();
		in.setBody("John Was Here");
		Producer producer = sendMail.createProducer();
		producer.start();
		producer.process(exchange);
		System.out.println("sent mail");
		Map<String, Object> headers = exchange.getOut().getHeaders();
		for (String key : headers.keySet()) {
			System.out.println(key + " " + headers.get(key));
		}

	}



--
View this message in context: http://camel.465427.n5.nabble.com/How-To-Get-The-SMTP-Message-ID-tp5724581.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How To Get The SMTP Message-ID

Posted by "John.R.Moore" <jo...@kronos.com>.
While I am building the libraries, I thought I would send a quick thank you
for the quick turnaround on the enhancement.   John



--
View this message in context: http://camel.465427.n5.nabble.com/How-To-Get-The-SMTP-Message-ID-tp5724581p5724602.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How To Get The SMTP Message-ID

Posted by Willem jiang <wi...@gmail.com>.
Hi  

I just checked the MailProducer, it doesn't store the Message Id to the camel message header.
So you cannot access the message header here.

I just fill a JIRA[1], and will commit a quick fix for it.

[1]https://issues.apache.org/jira/browse/CAMEL-5910
--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem


Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


On Tuesday, December 25, 2012 at 2:11 AM, John.R.Moore wrote:

> I have a system where I need to record the SMTP Message-ID for every sent
> message and use to correlate back responses. I followed the simple sending
> via SMTP examples from http://camel.apache.org/mail.html and had hoped to
> find the returned reference somewhere in the exchange to no avail.  
>  
> Is the message-id available in the exchange and I'm just not finding it or
> do I need to handle the sending of the SMTP message myself and push into the
> exchange.out?
>  
> Thanks in advance,
> John
>  
> <route id="sendToMail">
> <from uri="direct:toSMTP"/>
> <pipeline>
> <to
> uri="smtps://smtp.mail.**********.com?username=johnmoore330@ymail.com (mailto:johnmoore330@ymail.com)&amp;password=**********&amp;to=******@*****.com&amp;from=*******@*****.com&amp;subject=offers"
> />
> <process ref="dummyProcessor" />
> </pipeline>
> <to uri="mock:sentmail"/>
> </route>
>  
>  
>  
> @Test
> public void testSmtpSend() throws Exception {
>  
> assertEquals(ServiceStatus.Started, context.getStatus());
>  
> Exchange exchange = sendMail.createExchange();
> Message in = exchange.getIn();
> in.setBody("John Was Here");
> Producer producer = sendMail.createProducer();
> producer.start();
> producer.process(exchange);
> System.out.println("sent mail");
> Map<String, Object> headers = exchange.getOut().getHeaders();
> for (String key : headers.keySet()) {
> System.out.println(key + " " + headers.get(key));
> }
>  
> }
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-To-Get-The-SMTP-Message-ID-tp5724581.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).




Re: How To Get The SMTP Message-ID

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Did you get any headers at all? See this FAQ
http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html

You may want to use hasOut to only access the OUT if there is actually
an OUT message.
If not then access the IN instead.

See the FAQ why.


On Mon, Dec 24, 2012 at 7:11 PM, John.R.Moore <jo...@kronos.com> wrote:
> I have a system where I need to record the SMTP Message-ID for every sent
> message and use to correlate back responses.   I followed the simple sending
> via SMTP examples from http://camel.apache.org/mail.html and had hoped to
> find the returned reference somewhere in the exchange to no avail.
>
> Is the message-id available in the exchange and I'm just not finding it or
> do I need to handle the sending of the SMTP message myself and push into the
> exchange.out?
>
> Thanks in advance,
> John
>
>                 <route id="sendToMail">
>                         <from uri="direct:toSMTP"/>
>                         <pipeline>
>                                 <to
> uri="smtps://smtp.mail.**********.com?username=johnmoore330@ymail.com&amp;password=**********&amp;to=******@*****.com&amp;from=*******@*****.com&amp;subject=offers"
> />
>                                 <process  ref="dummyProcessor" />
>                         </pipeline>
>                         <to uri="mock:sentmail"/>
>                 </route>
>
>
>
>         @Test
>         public void testSmtpSend() throws Exception {
>
>                 assertEquals(ServiceStatus.Started, context.getStatus());
>
>                 Exchange exchange = sendMail.createExchange();
>                 Message in = exchange.getIn();
>                 in.setBody("John Was Here");
>                 Producer producer = sendMail.createProducer();
>                 producer.start();
>                 producer.process(exchange);
>                 System.out.println("sent mail");
>                 Map<String, Object> headers = exchange.getOut().getHeaders();
>                 for (String key : headers.keySet()) {
>                         System.out.println(key + " " + headers.get(key));
>                 }
>
>         }
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-To-Get-The-SMTP-Message-ID-tp5724581.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen