The tag mail allows building and sending emails.

1 mail

<mail
    to='smtphost'
    smtphost='smtphost'
    from='from'
    cc='cc'
    bcc='bcc'
    subject='subject'
    encoding='encoding'
    addReadReceiptHeader='true|false'
    addDeliveryReceiptHeader='true|false'
    user='user'
    password='password'
    port='port'
    timeout='timeout'
    localhost='localhost'
    localaddress='localaddress'
    localport='localport'
    auth='auth'
    submiter='submiter'
    dsn.notify='dsn.notify'
    dsn.ret='FULL|HDRS'
    allow8bitmime='true|false'
    sendpartial='true|false'
    quitwait='true|false'
    reportsuccess='true|false'
    socketFactory.class='socketFactory.class'
    socketFactory.fallback='true|false'
    socketFactory.port='socketFactory.port'
    starttls.enable='true|false'
    usereset='true|false'
    proxySet='proxySet'
    socksProxyHost='socksProxyHost'
    socksProxyPort='socksProxyPort'
    socksProxyPort='socksProxyPort'
>
    <content type='text/html'> *
        <cdata /> +
    </content>
    <attachs> *
        <mail.attach
            type='type'
            name='name'
            zip='true|false'
        > *
            <file /> !
        </mail.attach>
        <array> ?
            <mail.attach
                type='type'
                zip='zip'
            > *
                <file /> !
            </mail.attach>
        </array>
    </attachs>
</mail>

Exceptions

must specify from attribute or log as user

It has not been specified the sender through the attribute from and the system is not able to obtain a sender through the username of the session.

must specify smtphost attribute or setup one for group

Example

Send an email message.

Copy
<xsql-script name='mail_sample1'>
    <body>
        <mail
            smtphost='mail.deister.net'
            from='sender@deister.es'
            to='receiver@deister.es'
            subject='Test 1'
            >
            <content>
                Email sent through Axional Studio XSQL-Script.
            </content>
        </mail>
    </body>
</xsql-script>

Sending a message using the smtphost attribute to indicate a certain email client.

2 Attached content

You can attach content to a email through the tag mail.attach

Example
Copy
<xsql-script name='mail_sample2'>
	<body>
		<mail
			smtphost='mail.deister.net'
			from='pcasellas@deister.es'
			to='pcc'
			subject='Test 2'
			>
			<content>
				Email with attached file sent through
				Axional Studio XSQL-Script.
			</content>
			<attachs>
				<mail.attach type='image/jpeg'>
					<file name='/path/snowfall.jpg' type='absolute' />
				</mail.attach>
			</attachs>
		</mail>
	</body>


</xsql-script>
Example

Send a email with an array of attached files.

Copy
<xsql-script name='send_mail'>
   <body>

       <array name='arr' />
       <array.add name='arr'>
           <mail.attach type='image/jpeg'><file type='absolute' name='tanque.jpg' /></mail.attach>
           <mail.attach type='application/ms-word'><file type='absolute' name='test.doc' zip='true'/></mail.attach>
       </array.add>
       <mail smtphost='mail.deister.net'
           from='dani@deister.es'
           to='dani@deister.es'
           subject='test'
           file-encoding='iso-8859-1'
           encoding='iso-8859-1'
       >
           <content type='text/plain'>
               Sending email with several attached files obtained from an array.
           </content>
           <attachs>
               <arr />
           </attachs>
       </mail>
   </body>

</xsql-script>
Example

Sending of a email with inline images.

Copy
<xsql-script name='test_mail_inline_images'>
    <body>
        <mail
            smtphost='192.168.10.9'
            from='info@noserver.org'
            to='no-reply@gmail.com'
            subject='test_mail_inline_images'
        >
            <content type='text/html'>
                Begin of the text
                <div><IMG SRC='cid:my_custom_mail_part_id_1' STYLE='width:200px;height:200px;'></div>
                More text
                <div><IMG SRC='cid:my_custom_mail_part_id_2' STYLE='width:200px;height:200px;'></div>
                End of the text
            </content>
            <attachs>
                <mail.attach type='image/gif' cid='my_custom_mail_part_id_1'>
                    <file name='c:\temp\img1.png' type='absolute' />
                </mail.attach>
                <mail.attach type='image/gif' cid='my_custom_mail_part_id_2'>
                    <file name='c:\temp\img2.png' type='absolute' />
                </mail.attach>
            </attachs>
        </mail>
    </body>
</xsql-script>

3 Sending of SMS using email

<mail> offers the possibility to send SMS messages (Short Message Service) to mobile devices.

For this, it is necessary to perform the following settings:

  1. Specify the telephone number in the field user_sms_phone of the table wic_user, for each one of the receivers of text messages.
  2. Indicate the email address for sending SMS, in the column group_sms_address of the table wic_user_groups, for each user group to which the target persons belong.

To be able to send SMS messages, the label <mail> should be used as an email, unically it should be informed as value of attribute to (destination email), the result of concatenate the telephone number of the receiving user, with the email of the group of the users to which belongs.

The service consist in a Linux gateway which when receive a email for a receiver of the type 34647474747<sms@empresa.com>, uses the telephone number to send the content of the same (only the first characters).

Example

Send a SMS text message.

Copy
<xsql-script name='mail_sample3'>
   <args>
       <arg name='p_usercode' type='string' />
   </args>
   <body>
       <if>
           <expr>
               <system.user.hasSMSEnabled code='#p_usercode' />
           </expr>
           <then>
               <set name='m_to'>
                   <string trim='true'>
                       <system.user.getSMSPhone   code='#p_usercode' />
                       <system.user.getSMSAddress code='#p_usercode' />
                   </string>
               </set>
               <mail to='#m_to' subject='test'>
                   <content type='text/plain'>test SMS</content>
               </mail>
               <println>SMS sent to <m_to/></println>
           </then>
           <else>
               <println>SMS sending service not configured</println>
           </else>
       </if>
   </body>

</xsql-script>

The function <system.user.hasSMSEnabled> returns the value true if the username specified in the attribute code, have set the phone number and the user group to which belong, dispose of an email to send SMS.

Thorugh <system.user.getSMSPhone> and <system.user.getSMSAddress> is obtained respectively, the phone number of the user and the email address of the group to he belongs.

The result of the execution shown by console, would be the followed:

Copy
SMS send to 34659539727<sms@deister.net>