camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gert Vanthienen <gert.vanthie...@skynet.be>
Subject Re: configuring smtp
Date Mon, 14 Apr 2008 09:21:40 GMT
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:user@host:port/name@address 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", "firstname.lastname@company.com")
> 			.setHeader("from", "firstname.lastname@company.com")
> 			.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
> <null@mail1.department.company.com>... 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
> <null@mail1.department.company.com>... User unknown
>
> It tries to use address <null@mail1.department.company.com> 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("firstname.lastname@company.com");
> 			msg.setFrom(ia);
> 			msg.setRecipients(Message.RecipientType.TO, 
> InternetAddress.parse("firstname.lastname@company.com"));
> 			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 ? 
>
>   


Mime
View raw message