Objects>Mail
Introduction Installation Beginning Admin Quick Ref FTP Server SMTP Server Database Security
Statements Objects String Parsing Events Queues Samples Special names Error Handling Accessories   Back
Caravan Business Server>Help>Objects>Mail
Syntax mail objectname
Text
A SMTP (Mail) object is created with the property "from" set as the login userid of the User.
SMTP (Mail) object can only be created by a logged in user.

An object of type mail represents a single mail message received or to be sent. The mail
object can be instantiated. It can also be created automatically on receipt of a mail. This object type is identical to VAR and can be used as such in all other ways.

Notes
1.      To send mail, a default SMTP Gateway has to specified in the Caravan.cnf file in the etc path:
smtpgateway mail.domain.com

2.      TCP/IP port 25 is used by Caravan for mail transactions. A listener is installed on this port automatically on startup. Caravan will accept incoming connections only if "mailaction" and "mailuser" scripts have been  implemented.

3.      Any output from  (mailuser,mailaction,maildeliverystatus) scripts are sent to
      the console unless redirected by explicit "output" statement.

4.      Currently all scripts are placed in the templates directory with .html extension.

Also refer to SMTP Server topic for more details on mails sent and received.
Sample   An example for sending mail:

<caravan>
      mail mymail
      mymail(to)="xyz@yahoo.com"
      mymail(to)="daniel@hotmail.com"  ; // 2nd user
      mymail(cc)="sales@caravanserver.com"
      mymail(cc)="support@caravanserver.com" ; //2nd CC
      mymail(subject)="This is a test for sending mail"
      mymail(text)="hello\nblah .. blah\n"
      mymail(attachment)=myfile(file)
</caravan>

The mail object is automatically queued.
      
      
Example
<caravan>
      user x;
      "mail for ";mail(to);" from ";mail(from);"\n"; // output to console the recipients' and senders' names
      x(userid)=mail(to)
      if x(uid)
      table t=mail.data
      t(text)=mail(text)
      t(from)=mail(from)
      t(subject)=mail(subject)
      t(attachment)=mail(attachment)
      // etc. etc
      else
      mail("smtpgateway")="nextcenter"
      endif
</caravan>

Example
<caravan>
      mail x
      file image="f:\images\picture.gif"
      x(to)="user@domain.com";// mandatory
      x(subject)="File with images"
      x(text)=" I am sending you a mail\r\nwith two attached images."
      x(attachment)=image(file)
      delete image
      file image="f:\images\picture1.gif"
      x(attachment)=image(file);// number of attachments and their size may be limited
                              // by the receiver smtp or intervening gateways
      x(smtpgateway)="localhost"; // optional; default will be used if not set

</caravan>
Properties To
cc
subject
Text
attachment
smtpgateway
Home       Back