<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsd:schema xmlns="http://www.mulesource.org/schema/mule/smtp/2.0"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:mule="http://www.mulesource.org/schema/mule/core/2.0"
            xmlns:email="http://www.mulesource.org/schema/mule/email/2.0"
            targetNamespace="http://www.mulesource.org/schema/mule/smtp/2.0"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified">

    <xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>
    <xsd:import namespace="http://www.mulesource.org/schema/mule/core/2.0" 
                schemaLocation="http://www.mulesource.org/schema/mule/core/2.0/mule.xsd" />
    <xsd:import namespace="http://www.mulesource.org/schema/mule/email/2.0"
                schemaLocation="http://www.mulesource.org/schema/mule/email/2.0/mule-email.xsd"/>

    <xsd:element name="connector" type="smtpConnectorType" substitutionGroup="mule:abstract-connector"/>

    <!-- separate base so that header is separate and in local namespace -->
    <xsd:complexType name="baseSmtpConnectorType">
        <xsd:complexContent>
            <xsd:extension base="mule:connectorType">
                <!-- seems like we should be able to better restrict some of these types -->
                <xsd:attribute name="bccAddresses" type="xsd:string">
                    <xsd:annotation>
                        <xsd:documentation>
                            Comma separated list of addresses for blind copies.
                        </xsd:documentation>
                    </xsd:annotation>
                </xsd:attribute>
                <xsd:attribute name="ccAddresses" type="xsd:string">
                    <xsd:annotation>
                        <xsd:documentation>
                            Comma separated list of addresses for copies.
                        </xsd:documentation>
                    </xsd:annotation>
                </xsd:attribute>
                <xsd:attribute name="contentType" type="xsd:string">
                    <xsd:annotation>
                        <xsd:documentation>
                            Mime type for the outgoing message.
                        </xsd:documentation>
                    </xsd:annotation>
                </xsd:attribute>
                <xsd:attribute name="fromAddress" type="xsd:string">
                    <xsd:annotation>
                        <xsd:documentation>
                            The from address for the outgoing message.
                        </xsd:documentation>
                    </xsd:annotation>
                </xsd:attribute>
                <xsd:attribute name="replyToAddresses" type="xsd:string">
                    <xsd:annotation>
                        <xsd:documentation>
                            The reply-to address for the outgoing message.
                        </xsd:documentation>
                    </xsd:annotation>
                </xsd:attribute>
                <xsd:attribute name="subject" type="xsd:string">
                    <xsd:annotation>
                        <xsd:documentation>
                            The default subject for the outgoing message if none is set in the message.
                        </xsd:documentation>
                    </xsd:annotation>
                </xsd:attribute>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:complexType name="smtpConnectorType">
        <xsd:complexContent>
            <xsd:extension base="baseSmtpConnectorType">
                <xsd:sequence minOccurs="0" maxOccurs="unbounded">
                    <xsd:element name="header" type="mule:keyValueType">
                        <xsd:annotation>
                            <xsd:documentation>
                                Additional header name and value, added to the message.
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="outbound-endpoint" type="outboundEndpointType" substitutionGroup="mule:abstract-outbound-endpoint"/>
    <xsd:complexType name="outboundEndpointType">
        <xsd:complexContent>
            <xsd:extension base="mule:outboundEndpointType">
                <xsd:attributeGroup ref="email:addressAttributes"/>
                <xsd:attributeGroup ref="addressProperties"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="endpoint" type="globalEndpointType" substitutionGroup="mule:abstract-global-endpoint"/>
    <xsd:complexType name="globalEndpointType">
        <xsd:complexContent>
            <xsd:extension base="mule:globalEndpointType">
                <xsd:attributeGroup ref="email:addressAttributes"/>
                <xsd:attributeGroup ref="addressProperties"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:attributeGroup name="addressProperties">
        <xsd:attribute name="to" type="xsd:string">
            <xsd:annotation>
                <xsd:documentation>
                    The destination for the email.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="from" type="xsd:string">
            <xsd:annotation>
                <xsd:documentation>
                    The address of the sender of the email.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="subject" type="xsd:string">
            <xsd:annotation>
                <xsd:documentation>
                    The email subject.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="cc" type="xsd:string">
            <xsd:annotation>
                <xsd:documentation>
                    A comma separated list of email addresses to carbon copy to.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="bcc" type="xsd:string">
            <xsd:annotation>
                <xsd:documentation>
                    A comma separated list of email addresses to blind carbon copy to.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="replyTo" type="xsd:string">
            <xsd:annotation>
                <xsd:documentation>
                    The address used by default if someone replies to the email.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
    </xsd:attributeGroup>

</xsd:schema>
