L.S.,
Just glanced over the source code, but I think you
- have to add a destination address to your MailComponent configuration
- have to add a user to the MailComponent configuration to become the
from address
According to the code comments, you can also specify everything in the
URI with this format smtp:[EMAIL PROTECTED]:port/[EMAIL PROTECTED] where the part
behind the / represents the destination address.
Gert
Gaffer wrote:
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 ?