java - Send email to myself using SMTP and Apache Camel -


i trying write apache camel route sending email myself, based on part 4 of tutorial:

https://camel.apache.org/tutorial-example-reportincident.html

from("file://target/subfolder") .setheader("subject", constant("new incident reported")) .convertbodyto(string.class) // send email .to("smtp://myid@localhost?password=&to=myname@mycompany.com"); 

but i'm getting this, , no email in inbox:

395  [main] debug org.apache.camel.example.reportincident. reportincidentroutestest  - routing rules are:  [eventdrivenconsumerroute[endpoint[direct:start] ->  delegate(delegate(pipeline[deadletterchannel[delegate(setheader(org.apache. camel.file.name, beanexpression[bean:org.apache.camel.example.reportincident. filenamegenerator@244aeb52 method: generatefilename])),  recipientlist[log:org.apache.camel.deadletterchannel?level=error]],  deadletterchannel[delegate(sendto(endpoint[velocity:mailbody.vm])),  recipientlist[log:org.apache.camel.deadletterchannel?level=error]],  deadletterchannel[delegate(sendto(endpoint[file://target/subfolder])),  recipientlist[log:org.apache.camel.deadletterchannel?level=error]]]))],  eventdrivenconsumerroute[endpoint[file://target/subfolder] ->  delegate(delegate(pipeline[deadletterchannel[delegate(setheader(to,  myname@mycompany.com)), recipientlist[log:org.apache.camel.deadletterchannel? level=error]], deadletterchannel[delegate(setheader(subject, new incident  reported)), recipientlist[log:org.apache.camel.deadletterchannel?level=error]],  deadletterchannel[delegate(org.apache.camel.processor. convertbodyprocessor@6e79839),  recipientlist[log:org.apache.camel.deadletterchannel?level=error]],  deadletterchannel[delegate(sendto(endpoint[smtp://myid@localhost? password=&to=myname@mycompany.com])), recipientlist[log:org.apache.camel.deadletterchannel?level=error]]]))]] 

i'm not sure why, or how can fix problem. seem getting these warnings when run test:

[warning] pom com.sun.xml.fastinfoset:fastinfoset:jar:1.2.2 invalid,  transitive dependencies (if any) not available,  enable debug logging more details [warning] pom com.sun.xml.bind:jaxb-impl:jar:2.1.7 invalid,  transitive dependencies (if any) not available,  enable debug logging more details [warning] pom com.sun.xml.bind:jaxb-xjc:jar:2.1.7 invalid,  transitive dependencies (if any) not available,  enable debug logging more details  ...  606  [main] warn  org.apache.camel.impl.converter.defaulttypeconverter  -  overriding type converter from: staticmethodtypeconverter:  public static java.lang.string org.apache.camel.converter.ioconverter. tostring(javax.xml.transform.source) throws javax.xml.transform. transformerexception,java.io.ioexception to: instancemethodtypeconverter: public  java.lang.string org.apache.camel.converter.jaxp.xmlconverter.tostring (javax.xml.transform.source) throws javax.xml.transform.transformerexception 

the debug , warn messages can ignored.

following route definition worked me using camel v2.12.3:

from("file://target/subfolder")     .log("working on file ${header.camelfilename}")     .setheader("subject", simple("new incident: ${header.camelfilename}"))     .to("my_id@smtp://localhost?password=my_password&to=myname@mycompany.com");  

after starting route, should see message such working on file xxx in log.

perhaps not camel routing problem smtp server on localhost. try send email smtp server using email client , check if receive email. example how using bash shell on macos can found here.

please, check if smtp server on localhost uses default port. if not, add port uri such localhost:my_port. smtp default 25, smtps 465. active port can checked using telnet such telnet servername 25.

the smtp server may not problem reading of files. check if files in target/subfolder readable , not locked camel, i.e. check if there no filename.camellock file.

finally, verify route keeps running , doesn't stop before files scanned, see http://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html more information that.

to summarize answer: start small, split large routes small ones , test them separately.

edit: recent source code of tutorial-example-reportincident can found here: https://github.com/apache/camel/tree/master/examples/camel-example-reportincident.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -