MAIL

TheĀ MAIL component enables sending emails. Learn how to use the MAIL component.

Library

Create a new library with the following jars (in this order):

Camel version Library jars
2.18.3

Routes

Now it's possible to create a route that uses this component. Here is the definition of the route:

<routes xmlns="http://camel.apache.org/schema/spring" xmlns:u="http://www.systar.com/aluminium/camel-util">
    <route>
        <from uri="timer:foo?repeatCount=1"/>
        
        <!-- The subject is stored in a header -->
        <setHeader headerName="subject">
            <constant>Very important message</constant>
        </setHeader>
        
        <!-- The recipient is also in a header -->
        <setHeader headerName="to">
            <constant>me@company.com</constant>
        </setHeader>
        
        <!-- The message of the email is the body -->
        <setBody>
            <constant>This is an important message</constant>
        </setBody>
        
        <!-- Send the email -->
        <to uri="smtps://smtp.gmail.com?username={{smtpUser}}&amp;password={{smtpP@ssword}}"/>
    </route>
</routes>

Related Links