I'm using what is suggested in this thread 
http://camel.465427.n5.nabble.com/configuring-mail-endpoint-tp474166.html
to add the STARTTLS command when using an SMTP endpoint to send an email.
However if I do that the message does not even reach the SMTP server.
I don't add the property mail.stmp.starttls.enable=true to the URI it
reaches the server.
This is the log:
2015-07-21 19:44:42,375 | TRACE | _smtp_injection] | MailProducer               
     
| 116 - org.apache.camel.camel-core - 2.13.4 | Starting producer:
Producer[smtp://xxxx:587?mail.smtp.starttls.enable=true&password=xxxxxx&username=SMTP_Injection]
2015-07-21 19:44:42,376 | TRACE | _smtp_injection] | MailBinding                
     
| 211 - org.apache.camel.camel-mail - 2.13.4 | Determined Content-Type:
text/plain
2015-07-21 19:44:42,376 | TRACE | _smtp_injection] | MailBinding                
     
| 211 - org.apache.camel.camel-mail - 2.13.4 | Using Content-Type text/plain
for BodyPart: javax.mail.internet.MimeBodyPart@1d3e0022
2015-07-21 19:44:42,376 | TRACE | _smtp_injection] | MailBinding                
     
| 211 - org.apache.camel.camel-mail - 2.13.4 | Adding attachments +++ start
+++
2015-07-21 19:44:42,376 | TRACE | _smtp_injection] | MailBinding                
     
| 211 - org.apache.camel.camel-mail - 2.13.4 | Attachment #0: Disposition:
attachment
2015-07-21 19:44:42,377 | TRACE | _smtp_injection] | MailBinding                
     
| 211 - org.apache.camel.camel-mail - 2.13.4 | Attachment #0: DataHandler:
javax.activation.DataHandler@517ac72d
2015-07-21 19:44:42,377 | TRACE | _smtp_injection] | MailBinding                
     
| 211 - org.apache.camel.camel-mail - 2.13.4 | Attachment #0: FileName:
123456.pdf
2015-07-21 19:44:42,377 | TRACE | _smtp_injection] | MailBinding                
     
| 211 - org.apache.camel.camel-mail - 2.13.4 | Attachment #0: ContentType:
text/plain
2015-07-21 19:44:42,377 | TRACE | _smtp_injection] | MailBinding                
     
| 211 - org.apache.camel.camel-mail - 2.13.4 | Adding attachments +++ done
+++
2015-07-21 19:44:42,377 | DEBUG | _smtp_injection] | MailProducer               
     
| 211 - org.apache.camel.camel-mail - 2.13.4 | Sending MimeMessage:
messageNumber=[0], from=[delivery.engine-m...@hp.com],
to=[pau.pac...@hp.com]
2015-07-21 19:44:42,378 | DEBUG | _smtp_injection] | DefaultJavaMailSender      
     
| 211 - org.apache.camel.camel-mail - 2.13.4 | Connecting to xxxxt:587

The last log that appears is the connecting to the SMTP server on port 587.
Camel does not give any error but connection is not taking place.
This is my code:
  String endpointURI = buildUri(destinationInfoParameters);
            Endpoint endpoint = camelContext.getEndpoint(endpointURI);
            MailEndpoint mailEndpoint = (MailEndpoint) endpoint;
            java.util.Properties properties = new Properties();
            properties.put("mail.smtp.starttls.enable", "true");
           
mailEndpoint.getConfiguration().setAdditionalJavaMailProperties(properties);
            Exchange exchange = mailEndpoint.createExchange();
            Message in = exchange.getIn();
...
 Producer producer = mailEndpoint.createProducer();
            producer.start();
            producer.process(exchange);
            producer.stop();

where buildUri is substantially:
 return "smtp://" + destinationInfoParameters.get("host") + ":" +
destinationInfoParameters.get("port") +
                "?username=" + destinationInfoParameters.get("username") +
"&password=" + destinationInfoParameters.get("password")+
                "&mail.smtp.starttls.enable=true";

Apart from activating the TRACE level in org.apache.camel.component.mail
is there any other log level that I can activate to further debug this?

Thanks




--
View this message in context: 
http://camel.465427.n5.nabble.com/STARTTLS-does-not-work-tp5769696.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to