I am using Spring ApplicationContext. I have configured SMTP component like
this

        <bean id="smtp"
                class="org.apache.camel.component.mail.MailComponent">
                <property name="configuration">
                        <bean
                                
class="org.apache.camel.component.mail.MailConfiguration">
                                <property name="host" 
value="mail1.department.company.com" />
                        </bean>
                </property>
        </bean>

Then I create a route in Java code: 

                from("file://data/input/?noop=true")
                        .setHeader("to", "[EMAIL PROTECTED]")
                        .setHeader("from", "[EMAIL PROTECTED]")
                        .setBody(constant("Test"))
                        .to("smtp://@");

It fails with error: 

Failed message 1: javax.mail.SendFailedException: Invalid Addresses;
  nested exception is:
        com.sun.mail.smtp.SMTPAddressFailedException: 550 5.1.1
<[EMAIL PROTECTED]>... User unknown
org.springframework.mail.MailSendException; nested exception details (1)
are:
Failed message 1:
javax.mail.SendFailedException: Invalid Addresses;
  nested exception is:
        com.sun.mail.smtp.SMTPAddressFailedException: 550 5.1.1
<[EMAIL PROTECTED]>... User unknown

It tries to use address <[EMAIL PROTECTED]> instead of the
one that I passed in a header in Java code. 

However this code works: 

                        Session dummySession = null;
                        Properties props = System.getProperties();
                        props.put("mail.smtp.host", 
"mail1.department.company.com");
                        Session session = Session.getDefaultInstance(props, 
null);
                        Message msg = new MimeMessage(session);
                        InternetAddress ia = new
InternetAddress("[EMAIL PROTECTED]");
                        msg.setFrom(ia);
                        msg.setRecipients(Message.RecipientType.TO, 
InternetAddress.parse("[EMAIL PROTECTED]"));
                        msg.setSubject("Test");
                        Multipart multipart = new MimeMultipart();
                        BodyPart messageBodyPart = new MimeBodyPart();
                        String htmlText = "Text";
                        messageBodyPart.setContent(htmlText, "text/html");
                        multipart.addBodyPart(messageBodyPart);
                        msg.setContent(multipart);
                        msg.setHeader("X-Mailer", "eInvoiceMailer");
                        msg.setSentDate(new Date());
                        Transport.send(msg);

How can I make Camel piece work ? 

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

Reply via email to