Examples

EXAMPLE USAGES

1. Send a document without a message:

  $ veldfire -t you@somewhere.com -s 'Your document' -x document.sxw 
  

2. Send a mail to a list (can be a multi-part message):

  $ cat list.msg | veldfire -t /etc/mailing.list -s '[list-name] Information'
  

3. Forward an email to a list, using a config section (procmail recipe):

  :0:
  * ^To.*list-name@domain.com.*
  * ^From.*allowed-poster@domain.com.*
  {
    :0 c
    | veldfire -n list-name

    :0
    mail/list-name
  }
 

Your .veldfirerc for this:

 [list-name]
 from=List Owner <list-name@domain.com>
 to=/var/list-members.txt
 logfile=/var/log/list-name.log
 loglevel=4
 host=mx.isp.com
 report=me@localhost
 

4. Send an email from a script:

  #!/bin/sh

  echo "Starting backup" > $LOGFILE
  echo "Backup: $DIR" >> $LOGFILE
  ...
  cat $LOGFILE | veldfire -t root -s '[backup] Report'
 

5. Send an email, and see what is going on:

  $ veldfire -g -i -t you@somewhere.com file.xml
  20060211 22.30.26 (23900)   ¤ 0.429347 : you@somewhere.com
  20060211 22.30.26 (23900) 0.048990 Sent: 1 Fail: 0

 

6. Integrate the Riverdrums library with your C programs:

  #include <rd/email.h>

  char *files[] = { "/etc/hosts", "/var/log/syslog", NULL };
  char *headers[] = { "Organisation: Riverdrums", "X-Advert: rds.sf.net", NULL };
  char *subj  = "[veldfire] My Subject";
  char *from  = "My Name <me@domain.com>";
  char *to    = "Your Name <you@domain.com>";
  int success, fail;

  //  host, port, from, to, subj, msg, file, headers, 
  // sendtimeout, recvtimeout, maxconnection, rdlog, success, fail

  if (RD__email("localhost", 25, from, to, subj, "msg: here you are", 
                files, headers, 10, 10, 128, NULL, &success, &fail) < 0) {
    fprintf(stderr, "Error: %s\n", RD__error());
  }

  // localhost:25, no files, no headers, default timeouts and connections, no log
  RD__email_default(from, to, subj, "message goes here");

  // from is taken as user@hostname
  // localhost:25, no files, no headers, default timeouts and connections, no log
  RD__email_quick(to, subj, "message: hello");

 // Same as RD__email_default(), but with attached files
  RD__email_files(from, to, subj, "files as requested", files);
 

  struct rdemail * e = RD__email_init();
  RD__email_set_host(e, "smtp.isp.com");
  RD__email_set_port(e, 25);
  RD__email_set_from(e, from);
  RD__email_set_to(e, to);
  RD__email_set_subject(e, subj);
  RD__email_add_files(e, files);
  RD__email_add_headers(e, headers);
  RD__email_set_timeouts(e, 10, 20);
  RD__email_send(e, "my message", &success, &failure);
 

 

 


Jason Armstrong <ja@riverdrums.com>