Tags:
create new tag
view all tags

.UTIL EMAIL

This subroutine is called to send an email. Multiple addresses are allowed, as are attachments. This relies on the public domain program 'mutt' to deliver the email. This must be installed on your server for this to work. Available in 5.5 and higher


Usage:

      PASS         <Email Result>             FIELD            SHARE? Y
      PASS         <type>                     FIELD            SHARE? N
      PASS         <value>                    FIELD            SHARE? N
      PASS         <type>                     FIELD            SHARE? N
      PASS         <value>                    FIELD            SHARE? N
      PASS         ... etc ...                FIELD            SHARE? N
      GOSUB    --- .UTIL EMAIL
      *        Check for errors
      IF       --- .UTIL EMAIL                NE

Description:

This subroutine can be used to send Email. You must have the public domain email client 'mutt' installed on your server, or write your own routine to use whatever email delivery system you have (see 'Customizing' below)

<email result> will contain any output from the email command. This must be PASSed with Share "Y" to return the value.

<type> and <value> must be PASSed in pairs. Type must be one of the following (case insensitive):

  • TO
  • CC
  • BCC
  • ATTACH
  • BODY
  • DIST
  • SUBJECT
  • FROM
  • REPLY TO
  • CONTENT
The expected values for <value> depend on <type>:
  • For 'TO', 'CC', 'BCC', the <value> should be a valid email address. You can PASS multiple pairs of <type> and <value>.
  • For 'ATTACH', <value> should be the complete path to the file you wish to attach to the email. Only one file can be attached, if you PASS an 'ATTACH'/File Name pair more than once, only the last file will be attached.
  • For 'BODY', <value> should be the text you want to included in the email. You can PASS multiple pairs of 'BODY' and text.
  • For 'DIST', <value> should be the name of an Email Distribution list you have defined in System Administration. The email addresses on the list will be expanded to the various 'To', 'CC', 'BCC' addresses. You can PASS multiple pairs of 'DIST' and list name.
  • For 'SUBJECT', <value> should be the subject of the email. If you PASS a 'SUBJECT'/text pair more than once, only the last subject will be used.
  • For 'FROM', <value> should be the email address you want to show as the 'from' address (optional). If you PASS a 'FROM'/address pair more than once, only the last address will be used.
  • For 'REPLY TO', <value> should be the email address you want to show as the 'reply to' address (optional). If you PASS a 'REPLY TO'/address pair more than once, only the last address will be used.
  • For 'CONTENT', <value> should be the email content type, either HTML or PLAIN (case insensitive). If you PASS a 'CONTENT'/type pair more than once, only the last one will be used.
If the environment variable APPX_EMAIL_LOG is set to a valid path/file name, the subroutine will log the generated command for debugging.

Customizing:

If you already have a command line program that you use to deliver email, you can hook the 0LA Subroutine .UTIL EMAIL SEND and use your own. When your subroutine is invoked, the following fields are populated and ready for you to use:

  • --- WORK EMAIL TO - To addresses

  • --- WORK EMAIL CC - CC addresses

  • --- WORK EMAIL BCC - BCC addresses

  • --- WORK EMAIL SUBJECT - Email subject

  • --- WORK EMAIL FILE - Files to attach

  • --- WORK EMAIL BODY - File name of body text

  • --- WORK EMAIL FROM - From address

  • --- WORK EMAIL REPLY TO - Reply to address

  • --- WORK EMAIL CONTENT - Email Content Type ( if non blank, it will contain text/plain or text/HTML)

  • --- WORK DATA DEBUG A Y/N flag to indicate if logging is active or not. If active, you can use .STREAM WRITE to write to the stream name F26DVTFD -LOG

You can set any messages from your command line email program into --- WORK EMAIL RESULT. If this field is non blank, .UTIL EMAIL will be set to 'Errors sending Email' and the value of WORK EMAIL RESULT returned in <email result>

Do not exit your subroutine via a RETURN statement, this will cause a runtime error. Your subroutine is invoked via a SUBR command, and so must either END or simply run out of code

Comments:

Read what other users have said about this page or add your own comments.


JeanNeron - 2020-01-23

Topic revision: r1 - 2020-01-23 - JeanNeron
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback