You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by siva naresh <vs...@gmail.com> on 2009/03/02 13:30:26 UTC

configuring mail endpoint

Please see the following code snippet..

Endpoint smtpEndPoint = context
				.getEndpoint("smtp://username@smtp.gmail.com:25?password=password");

    try {
              producer = smtpEndPoint .createProducer();
              Exchange ex = producer.createExchange();
	      ex.getIn().setBody("hello");		
	       producer.process(ex);
      } catch (Exception e) {
			e.printStackTrace();
     }

throws 
com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS
command first. 6sm5357658qwd.33


I figured out that I need to set the following property
mail.smtp.starttls.enable=true for the above exception.

how do I do set the above property using URI or is there any workaround?
-- 
View this message in context: http://www.nabble.com/configuring-mail-endpoint-tp22287281p22287281.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: configuring mail endpoint

Posted by siva naresh <vs...@gmail.com>.
Hi, 
       Thanks for replying. I forgot to put producer.start() statement in
the code. 
Even after doing so.. the same exception occurs.. 


Claus Ibsen-2 wrote:
> 
> Hi
> 
> You need to start the producer first, and stop it after use
> 
> producer.start()
> // use producer as much you like
> producer.stop() eg when you app shutdown or you dont need the producer
> anymore
> 
> You know this is low level coding? Camel has a higher level API
> For instance you can use a ProducerTemplate to send an email in 1 line of
> code
> 
> This template however need also to be started / stopped. You can
> however just create 1 shared instance and keep it around and stop it
> when you shutdown
> 
> 
> On Mon, Mar 2, 2009 at 1:30 PM, siva naresh <vs...@gmail.com> wrote:
>>
>> Please see the following code snippet..
>>
>> Endpoint smtpEndPoint = context
>>                              
>>  .getEndpoint("smtp://username@smtp.gmail.com:25?password=password");
>>
>>    try {
>>              producer = smtpEndPoint .createProducer();
>>              Exchange ex = producer.createExchange();
>>              ex.getIn().setBody("hello");
>>               producer.process(ex);
>>      } catch (Exception e) {
>>                        e.printStackTrace();
>>     }
>>
>> throws
>> com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a
>> STARTTLS
>> command first. 6sm5357658qwd.33
>>
>>
>> I figured out that I need to set the following property
>> mail.smtp.starttls.enable=true for the above exception.
>>
>> how do I do set the above property using URI or is there any workaround?
>> --
>> View this message in context:
>> http://www.nabble.com/configuring-mail-endpoint-tp22287281p22287281.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/configuring-mail-endpoint-tp22287281p22287447.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: configuring mail endpoint

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

You need to start the producer first, and stop it after use

producer.start()
// use producer as much you like
producer.stop() eg when you app shutdown or you dont need the producer anymore

You know this is low level coding? Camel has a higher level API
For instance you can use a ProducerTemplate to send an email in 1 line of code

This template however need also to be started / stopped. You can
however just create 1 shared instance and keep it around and stop it
when you shutdown


On Mon, Mar 2, 2009 at 1:30 PM, siva naresh <vs...@gmail.com> wrote:
>
> Please see the following code snippet..
>
> Endpoint smtpEndPoint = context
>                                .getEndpoint("smtp://username@smtp.gmail.com:25?password=password");
>
>    try {
>              producer = smtpEndPoint .createProducer();
>              Exchange ex = producer.createExchange();
>              ex.getIn().setBody("hello");
>               producer.process(ex);
>      } catch (Exception e) {
>                        e.printStackTrace();
>     }
>
> throws
> com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS
> command first. 6sm5357658qwd.33
>
>
> I figured out that I need to set the following property
> mail.smtp.starttls.enable=true for the above exception.
>
> how do I do set the above property using URI or is there any workaround?
> --
> View this message in context: http://www.nabble.com/configuring-mail-endpoint-tp22287281p22287281.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/

Re: configuring mail endpoint

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Mar 2, 2009 at 2:40 PM, siva naresh <vs...@gmail.com> wrote:
>
> Hi,
>
>     we are developing the application for generic endpoints.. and we do not
> want to
> to check the instance of the endpoint with the instance of MailEndpoint and
> set the properties..
>
> Is there a way to enter the property(mail.smtp.starttls.enable=true) via the
> URI.. in Camel 1.5?
> or get the property from the spring configuration file.
No. You can set it as a JVM system property :)

You can configure the endpoint manaually in Spring using the <bean id=
class=> regular spring bean style.
This has been enhanced greatly in Camel 2.0 so nearly all endpoints
can be created 100% from spring bean style.

So I am afraid you are a bit out of luck since you dont want to set it
in Java. You can after all just use an instanceof check to see if its
a mail endpoint.

>
>
>
> Claus Ibsen-2 wrote:
>>
>> On Mon, Mar 2, 2009 at 1:30 PM, siva naresh <vs...@gmail.com> wrote:
>>>
>>> Please see the following code snippet..
>>>
>>> Endpoint smtpEndPoint = context
>>>
>>>  .getEndpoint("smtp://username@smtp.gmail.com:25?password=password");
>>>
>>>    try {
>>>              producer = smtpEndPoint .createProducer();
>>>              Exchange ex = producer.createExchange();
>>>              ex.getIn().setBody("hello");
>>>               producer.process(ex);
>>>      } catch (Exception e) {
>>>                        e.printStackTrace();
>>>     }
>>>
>>> throws
>>> com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a
>>> STARTTLS
>>> command first. 6sm5357658qwd.33
>>>
>>>
>>> I figured out that I need to set the following property
>>> mail.smtp.starttls.enable=true for the above exception.
>>>
>>> how do I do set the above property using URI or is there any workaround?
>> In Camel 2.0 you just add it as an URI option. In Came 1.x you can not do
>> this.
>>
>> But since you use java code you can case the endpoint to MailEndpoint.
>> And there should be a getter for mail properties or what its named.
>> And there you should be able to add/set properties.
>>
>> MailEndpoint -> MailConfiguration -> AdditionalJavaMailProperties
>>
>> Or you can add it is a system property and Camel will use it also.
>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/configuring-mail-endpoint-tp22287281p22287281.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>>
>>
>
> --
> View this message in context: http://www.nabble.com/configuring-mail-endpoint-tp22287281p22288278.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/

Re: configuring mail endpoint

Posted by siva naresh <vs...@gmail.com>.
Hi,

     we are developing the application for generic endpoints.. and we do not
want to 
to check the instance of the endpoint with the instance of MailEndpoint and
set the properties..

Is there a way to enter the property(mail.smtp.starttls.enable=true) via the
URI.. in Camel 1.5?
or get the property from the spring configuration file. 



Claus Ibsen-2 wrote:
> 
> On Mon, Mar 2, 2009 at 1:30 PM, siva naresh <vs...@gmail.com> wrote:
>>
>> Please see the following code snippet..
>>
>> Endpoint smtpEndPoint = context
>>                              
>>  .getEndpoint("smtp://username@smtp.gmail.com:25?password=password");
>>
>>    try {
>>              producer = smtpEndPoint .createProducer();
>>              Exchange ex = producer.createExchange();
>>              ex.getIn().setBody("hello");
>>               producer.process(ex);
>>      } catch (Exception e) {
>>                        e.printStackTrace();
>>     }
>>
>> throws
>> com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a
>> STARTTLS
>> command first. 6sm5357658qwd.33
>>
>>
>> I figured out that I need to set the following property
>> mail.smtp.starttls.enable=true for the above exception.
>>
>> how do I do set the above property using URI or is there any workaround?
> In Camel 2.0 you just add it as an URI option. In Came 1.x you can not do
> this.
> 
> But since you use java code you can case the endpoint to MailEndpoint.
> And there should be a getter for mail properties or what its named.
> And there you should be able to add/set properties.
> 
> MailEndpoint -> MailConfiguration -> AdditionalJavaMailProperties
> 
> Or you can add it is a system property and Camel will use it also.
> 
>> --
>> View this message in context:
>> http://www.nabble.com/configuring-mail-endpoint-tp22287281p22287281.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/configuring-mail-endpoint-tp22287281p22288278.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: configuring mail endpoint

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Mar 2, 2009 at 1:30 PM, siva naresh <vs...@gmail.com> wrote:
>
> Please see the following code snippet..
>
> Endpoint smtpEndPoint = context
>                                .getEndpoint("smtp://username@smtp.gmail.com:25?password=password");
>
>    try {
>              producer = smtpEndPoint .createProducer();
>              Exchange ex = producer.createExchange();
>              ex.getIn().setBody("hello");
>               producer.process(ex);
>      } catch (Exception e) {
>                        e.printStackTrace();
>     }
>
> throws
> com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS
> command first. 6sm5357658qwd.33
>
>
> I figured out that I need to set the following property
> mail.smtp.starttls.enable=true for the above exception.
>
> how do I do set the above property using URI or is there any workaround?
In Camel 2.0 you just add it as an URI option. In Came 1.x you can not do this.

But since you use java code you can case the endpoint to MailEndpoint.
And there should be a getter for mail properties or what its named.
And there you should be able to add/set properties.

MailEndpoint -> MailConfiguration -> AdditionalJavaMailProperties

Or you can add it is a system property and Camel will use it also.

> --
> View this message in context: http://www.nabble.com/configuring-mail-endpoint-tp22287281p22287281.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/