<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://www.springframework.org/schema/integration/mail"
		xmlns:xsd="http://www.w3.org/2001/XMLSchema"
		xmlns:beans="http://www.springframework.org/schema/beans"
		xmlns:tool="http://www.springframework.org/schema/tool"
		xmlns:integration="http://www.springframework.org/schema/integration"
		targetNamespace="http://www.springframework.org/schema/integration/mail"
		elementFormDefault="qualified"
		attributeFormDefault="unqualified">

	<xsd:import namespace="http://www.springframework.org/schema/beans"/>
	<xsd:import namespace="http://www.springframework.org/schema/tool"/>
	<xsd:import namespace="http://www.springframework.org/schema/integration"
			schemaLocation="http://www.springframework.org/schema/integration/spring-integration-2.1.xsd"/>

	<xsd:annotation>
		<xsd:documentation><![CDATA[
	Defines the configuration elements for Spring Integration's Mail Channel Adapters.
		]]></xsd:documentation>
	</xsd:annotation>

	<xsd:element name="outbound-channel-adapter">
		<xsd:complexType>
			<xsd:annotation>
				<xsd:documentation>
	Defines an outbound mail-sending Channel Adapter.
				</xsd:documentation>
			</xsd:annotation>
			<xsd:sequence>
				<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1"/>
			</xsd:sequence>
			<xsd:attribute name="id" type="xsd:string"/>
			<xsd:attribute name="channel" type="xsd:string">
				<xsd:annotation>
					<xsd:appinfo>
						<tool:annotation kind="ref">
							<tool:expected-type type="org.springframework.integration.MessageChannel"/>
						</tool:annotation>
					</xsd:appinfo>
				</xsd:annotation>
			</xsd:attribute>
			<xsd:attribute name="mail-sender" type="xsd:string">
				<xsd:annotation>
					<xsd:appinfo>
						<tool:annotation kind="ref">
							<tool:expected-type type="org.springframework.mail.MailSender"/>
						</tool:annotation>
					</xsd:appinfo>
				</xsd:annotation>
			</xsd:attribute>
			<xsd:attribute name="host" type="xsd:string"/>
			<xsd:attribute name="port" type="xsd:string"/>
			<xsd:attribute name="username" type="xsd:string"/>
			<xsd:attribute name="password" type="xsd:string"/>
			<xsd:attribute name="java-mail-properties" type="xsd:string">
				<xsd:annotation>
					<xsd:appinfo>
						<tool:annotation kind="ref">
							<tool:expected-type type="java.util.Properties"/>
						</tool:annotation>
					</xsd:appinfo>
				</xsd:annotation>
			</xsd:attribute>
			<xsd:attribute name="auto-startup" type="xsd:string" default="true"/>
			<xsd:attribute name="order">
				<xsd:annotation>
					<xsd:documentation>
						Specifies the order for invocation when this endpoint is connected as a
						subscriber to a SubscribableChannel.
					</xsd:documentation>
				</xsd:annotation>
			</xsd:attribute>
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="inbound-channel-adapter">
		<xsd:annotation>
			<xsd:documentation>
	Defines an inbound Channel Adapter that polls a mailbox for mail messages.
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:complexContent>
				<xsd:extension base="inboundMailAdapterType">
					<xsd:sequence>
						<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1"/>
					</xsd:sequence>
					<xsd:attribute name="protocol" type="xsd:string">
						<xsd:annotation>
							<xsd:documentation><![CDATA[
	The protocol to use (e.g. "pop3" or "imap"). Typically, either this or the 'store-uri' would be
	provided, but not both. However, at least one of them is required.
							]]></xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
				</xsd:extension>
			</xsd:complexContent>
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="imap-idle-channel-adapter">
		<xsd:annotation>
			<xsd:documentation>
	Defines an IMAP IDLE channel adapter.
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:complexContent>
				<xsd:extension base="inboundMailAdapterType">
					<xsd:attribute name="error-channel" type="xsd:string">
						<xsd:annotation>
							<xsd:appinfo>
								<tool:annotation kind="ref">
									<tool:expected-type
										type="org.springframework.integration.MessageChannel" />
								</tool:annotation>
							</xsd:appinfo>
							<xsd:documentation>
								If a (synchronous) downstream exception is thrown and an error-channel is specified,
								the MessagingException will be sent to this channel. Otherwise, any such exception
								will simply be logged as a warning by the channel adapter.
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
				</xsd:extension>
			</xsd:complexContent>
		</xsd:complexType>
	</xsd:element>

	<xsd:complexType name="inboundMailAdapterType">
		<xsd:attribute name="id" type="xsd:string">
			<xsd:annotation>
				<xsd:documentation>
	A unique identifier for this Channel Adapter.
				</xsd:documentation>
			</xsd:annotation>
		</xsd:attribute>
		<xsd:attribute name="channel" type="xsd:string">
			<xsd:annotation>
				<xsd:documentation>
	Reference for the MessageChannel to which this adapter will send Messages.
				</xsd:documentation>
				<xsd:appinfo>
					<tool:annotation kind="ref">
						<tool:expected-type type="org.springframework.integration.MessageChannel"/>
					</tool:annotation>
				</xsd:appinfo>
			</xsd:annotation>
		</xsd:attribute>
		<xsd:attribute name="store-uri" type="xsd:string">
			<xsd:annotation>
				<xsd:documentation><![CDATA[
	The URI for the Mail Store. Typically of the form: [pop3|imap]://user:password@host:port/INBOX
	If this is not provided, then the store will be retrieved via the no-arg Session.getStore()
	instead of the Session.getStore(url) method.
				]]></xsd:documentation>
			</xsd:annotation>
		</xsd:attribute>
		<xsd:attribute name="mail-filter-expression" type="xsd:string">
			<xsd:annotation>
				<xsd:documentation><![CDATA[
	Allows you to provide a SpEL expression which defines a fine grained filtering criteria for the mail messages to be processed by this adapter.
				]]></xsd:documentation>
			</xsd:annotation>
		</xsd:attribute>
		<xsd:attribute name="session" type="xsd:string">
			<xsd:annotation>
				<xsd:documentation>
	Specify the javax.mail.Session reference.
	NOTE: if this is provided, then 'java-mail-properties' should not be.
				</xsd:documentation>
				<xsd:appinfo>
					<tool:annotation kind="ref">
						<tool:expected-type type="javax.mail.Session"/>
					</tool:annotation>
				</xsd:appinfo>
			</xsd:annotation>
		</xsd:attribute>
		<xsd:attribute name="java-mail-properties" type="xsd:string">
			<xsd:annotation>
				<xsd:documentation>
	Reference to a 'java.util.Properties' instance with settings for the JavaMail Session.
	NOTE: if this is provided, then 'session' should not be.
				</xsd:documentation>
				<xsd:appinfo>
					<tool:annotation kind="ref">
						<tool:expected-type type="java.util.Properties"/>
					</tool:annotation>
				</xsd:appinfo>
			</xsd:annotation>
		</xsd:attribute>
		<xsd:attribute name="authenticator" type="xsd:string">
			<xsd:annotation>
				<xsd:documentation>
	Specify the javax.mail.Authenticator.
	NOTE: if this is provided, then 'session' should not be.
				</xsd:documentation>
				<xsd:appinfo>
					<tool:annotation kind="ref">
						<tool:expected-type type="javax.mail.Authenticator"/>
					</tool:annotation>
				</xsd:appinfo>
			</xsd:annotation>
		</xsd:attribute>
		<xsd:attribute name="max-fetch-size" type="xsd:string">
			<xsd:annotation>
				<xsd:documentation><![CDATA[
	Specify the maximum number of Mail Messages to fetch per receive call.
				]]></xsd:documentation>
			</xsd:annotation>
		</xsd:attribute>
		<xsd:attribute name="should-delete-messages" type="xsd:string" use="required">
			<xsd:annotation>
				<xsd:documentation><![CDATA[
	Specify whether mail messages should be deleted after retrieval.
				]]></xsd:documentation>
			</xsd:annotation>
		</xsd:attribute>
		<xsd:attribute name="should-mark-messages-as-read" type="xsd:string" use="optional" default="true">
			<xsd:annotation>
				<xsd:documentation><![CDATA[
	Specify whether mail messages should be marked as read aftre being retrieved (Not supported in POP3).
				]]></xsd:documentation>
			</xsd:annotation>
		</xsd:attribute>
		<xsd:attribute name="auto-startup" type="xsd:string" default="true">
			<xsd:annotation>
				<xsd:documentation>
	Specify whether this endpoint should be started automatically. The default is TRUE.
				</xsd:documentation>
			</xsd:annotation>
		</xsd:attribute>
	</xsd:complexType>

	<xsd:element name="mail-to-string-transformer">
		<xsd:complexType>
			<xsd:annotation>
				<xsd:documentation>
	Defines a Transformer that converts a javax.mail.Message payload to a String.
				</xsd:documentation>
			</xsd:annotation>
			<xsd:complexContent>
				<xsd:extension base="transformerType">
					<xsd:attribute name="charset" type="xsd:string"/>
				</xsd:extension>
			</xsd:complexContent>
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="header-enricher">
		<xsd:complexType>
			<xsd:annotation>
				<xsd:documentation>
	Defines a Transformer for adding statically configured Mail Headers.
				</xsd:documentation>
			</xsd:annotation>
			<xsd:complexContent>
				<xsd:extension base="transformerType">
					<xsd:choice minOccurs="1" maxOccurs="unbounded">
						<xsd:element name="subject" type="headerType"/>
						<xsd:element name="to" type="headerType"/>
						<xsd:element name="cc" type="headerType"/>
						<xsd:element name="bcc" type="headerType"/>
						<xsd:element name="from" type="headerType"/>
						<xsd:element name="reply-to" type="headerType"/>
						<xsd:element name="content-type" type="headerType"/>
						<xsd:element name="attachment-filename" type="headerType"/>
						<xsd:element name="multipart-mode" type="headerType"/>
					</xsd:choice>
					<xsd:attribute name="default-overwrite">
						<xsd:annotation>
							<xsd:documentation>
	Specify the default boolean value for whether to overwrite existing header values. This will only take effect for
	sub-elements that do not provide their own 'overwrite' attribute. If the 'default-overwrite' attribute is not
	provided, then the specified header values will NOT overwrite any existing ones with the same header names. 
							</xsd:documentation>
						</xsd:annotation>
						<xsd:simpleType>
							<xsd:union memberTypes="xsd:boolean xsd:string"/>
						</xsd:simpleType> 
					</xsd:attribute>
				</xsd:extension>
			</xsd:complexContent>
		</xsd:complexType>
	</xsd:element>

	<xsd:complexType name="headerType">
		<xsd:attribute name="value" type="xsd:string" />
		<xsd:attribute name="ref" type="xsd:string" />
		<xsd:attribute name="expression" type="xsd:string" />
		<xsd:attribute name="overwrite">
			<xsd:annotation>
				<xsd:documentation>
	Boolean value to indicate whether this header value should overwrite an existing header value for the same name.
				</xsd:documentation>
			</xsd:annotation>
			<xsd:simpleType>
				<xsd:union memberTypes="xsd:boolean xsd:string"/>
			</xsd:simpleType>
		</xsd:attribute>
	</xsd:complexType>

	<xsd:complexType name="transformerType">
		<xsd:attribute name="id" type="xsd:string"/>
		<xsd:attribute name="input-channel" type="xsd:string">
			<xsd:annotation>
				<xsd:appinfo>
					<tool:annotation kind="ref">
						<tool:expected-type type="org.springframework.integration.MessageChannel"/>
					</tool:annotation>
				</xsd:appinfo>
			</xsd:annotation>
		</xsd:attribute>
		<xsd:attribute name="output-channel" type="xsd:string">
			<xsd:annotation>
				<xsd:appinfo>
					<tool:annotation kind="ref">
						<tool:expected-type type="org.springframework.integration.MessageChannel"/>
					</tool:annotation>
				</xsd:appinfo>
			</xsd:annotation>
		</xsd:attribute>		
	</xsd:complexType>

</xsd:schema>
