Setting Up Mailman For External Email

Introductions and Apologies
VISTA Mailman is standards compliant email server; it can send and receive emails. However, it does not comply with the newer standards (e.g. ESMTP).

Before you start doing anything, you need to make sure that Taskman is running and that the VISTA Background Mail Filer is running. I won't show you how to start Taskman (way way off topic), but I will show up how to check the filer.

 GTM>S DUZ=111 D ^XUP

Setting up programmer environment This is a TEST account.

Terminal Type set to: C-VT102

Select OPTION NAME: XMMGR 1  XMMGR       Manage Mailman 2  XMMGR-BACKGROUND-FILER       Background Filer (XMAD) 3  XMMGR-BKFILER-ACT       Active Users/Deliveries Report 4  XMMGR-BKFILER-EDIT-NORMALIZED       Edit numbers to Normalize Reports 5  XMMGR-BKFILER-GROUP       Deliveries by Group Press  to see more, '^' to exit this list, OR CHOOSE 1-5: 1 XMMGR     Manage Mailman

Create a Mailbox for a user Disk Space Management ...         Group/Distribution Management ...          Local Delivery Management ... MailMan Site Parameters Network Management ... New Features for Managing MailMan

Select Manage Mailman Option: LOCAL Delivery Management

Active Users/Deliveries Report CHECK background filer Compile Response Time Statistics Deliveries by Group Delivery Queue Statistics Collection Edit numbers to Normalize Reports Graphics Download (TAB separators) Log Response Time Toggler Mail Delivery Statistics Report New Messages and Logon Statistics START background filer STOP background filer

Select Local Delivery Management Option: CHECK background filer

Delivery Queue Status as of 5/18/2011@14:13:04

Deliveries COMPLETED since last 1/2 hour: 19122 (19113 Msg, 9 Resp) Number of delivery queues: 1 Message and 1 Response Nothing waiting to be put in the delivery queues.

Nothing in the delivery queues.

Background filer status: Background Filers are running.

Refresh? Yes// NO

If it isn't running, go ahead and start it.

Sending
Most people want to send email to the outside world from VISTA. So we will start with that.

First you need to set-up an Email Server that accepts unauthenticated email via SMTP and relays it to the outside world. If you have an old style smtp relay server from your ISP, that will suffice. If you, like me, have a server that will only accept TLS encyrpted and Authenticated SMTP, you can't send email directly from VISTA. Instead, you need to send it to a relay that will forward your email. I have had pretty good luck with postfix.

I saw this article for setting up Postfix as a relay server for email; and that's what I used to get postfix to authenticate against my company's smtp server that uses STARTTLS. http://www.marksanborn.net/linux/send-mail-postfix-through-gmails-smtp-on-a-ubuntu-lts-server/

Before, doing anything with VISTA, make sure you can send emails from the VISTA machine using roll and scroll. Easiest way is to telnet into your mail server smtp port and send a message using SMTP (vide http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol).

Here's an example:

 sam@sam-desktop:~/pocn-moh$ telnet localhost 10025 Trying ::1... Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 sam-desktop ESMTP Postfix (Ubuntu) HELO relay.example.org 250 sam-desktop MAIL FROM: 250 2.1.0 Ok RCPT TO: 250 2.1.5 Ok DATA 354 End data with . From: "Bob Example"  To: "Alice Example"  Date: Tue, 15 Jan 2008 16:02:43 -0500 Subject: Test message

Hello Alice. Bye Alice. . 250 2.0.0 Ok: queued as 62184840557 QUIT 221 2.0.0 Bye Connection closed by foreign host.

Now you would check your email to see if you have gotten any mail. If you did, we are in business.

If you have an unauthenticated SMTP, make an new entry in the Domain file like this, assuming that your SMTP is smtp.example.com.

 NAME: smtp.example.com                 FLAGS: S  MAILMAN HOST: smtp.example.com        DISABLE TURN COMMAND: YES TRANSMISSION SCRIPT: TOMYSMTP          PRIORITY: 1 NUMBER OF ATTEMPTS: 4                TYPE: TCP/IP Channel PHYSICAL LINK / DEVICE: NULL NETWORK ADDRESS (MAILMAN HOST): smtp.example.com TEXT: O H="smtp.example.com",P=TCP/GTM C TCPCHAN-SOCKET25/GTM SYNONYM: NET SYNONYM: COM SYNONYM: ORG SYNONYM: JO

These synonyms turn out to be important. VISTA will look for the email domain suffix, and match it against a domain. By default, VISTA will send email to your parent domain if it can't match the domain suffix.

Now, what if you don't have an unencrypted unauthenticated SMTP server to send to? Well, in that case, you need to send your emails to a relay mail agent who logs in and encrypts data on your behalf.

In that case, your domain will look like this (I setup postfix on my localhost, so postfix is located at 127.0.0.1. If your postfix or other relay server is else where, put the correct ip address).

 NAME: 127.0.0.1                        FLAGS: S  MAILMAN HOST: 127.0.0.1               DISABLE TURN COMMAND: YES TRANSMISSION SCRIPT: TOGMAIL           PRIORITY: 1 NUMBER OF ATTEMPTS: 4                TYPE: TCP/IP Channel PHYSICAL LINK / DEVICE: NULL NETWORK ADDRESS (MAILMAN HOST): 127.0.0.1 TEXT: O H="127.0.0.1",P=TCP/GTM C TCPCHAN-SOCKET25/GTM SYNONYM: NET SYNONYM: COM SYNONYM: ORG SYNONYM: JO

You have to try to see if your settings have worked:  GTM>D ^XUP

Setting up programmer environment This is a TEST account.

Terminal Type set to: C-VT102

Select OPTION NAME: XMMGR 1  XMMGR       Manage Mailman 2  XMMGR-BACKGROUND-FILER       Background Filer (XMAD) 3  XMMGR-BKFILER-ACT       Active Users/Deliveries Report 4  XMMGR-BKFILER-EDIT-NORMALIZED       Edit numbers to Normalize Reports 5  XMMGR-BKFILER-GROUP       Deliveries by Group Press  to see more, '^' to exit this list, OR CHOOSE 1-5: 1 XMMGR     Manage Mailman

Create a Mailbox for a user Disk Space Management ...         Group/Distribution Management ...          Local Delivery Management ... MailMan Site Parameters Network Management ... New Features for Managing MailMan

Select Manage Mailman Option: NETWOrk Management

Christen a domain Compare Domains in System Against Released List Network Help Queue Management ... Site Parameters Transmission Management ...

Select Network Management Option: TRAnsmission Management

Edit a script Play a script Receive Messages from Another UCI Send Messages to Another UCI Sequential Media Message Reception Sequential Media Queue Transmission Subroutine editor Toggle a script out of service Validation Number Edit

Select Transmission Management Option: PLAY a script Select DOMAIN NAME: 127.0.0.1                         0 msgs

# Script Name              Type      Priority -- ---                      1  TOGMAIL                  TCPCHAN    1

14:38:28 To 127.0.0.1 from MOH.AMMAN.JO on 5/18/2011 14:38:28 Script: TOGMAIL 14:38:28 O H="127.0.0.1",P=TCP/GTM 14:38:28 Channel opened to 127.0.0.1 14:38:28 Device 'NULL', Protocol 'TCP/GTM' (file 3.4) 14:38:28 C TCPCHAN-SOCKET10025/GTM 14:38:28 Calling script 'TCPCHAN-SOCKET10025/GTM' (file 4.6) 14:38:28 Xecuting 'L +^XMBX("TCPCHAN",XMHOST):99 E S ER=1,XMER="CHANNEL IN USE" ' 14:38:28 Xecuting 'S X="ERRSCRPT^XMRTCP",@^%ZOSF("TRAP")' 14:38:28 Xecuting 'S XMRPORT=$G(XMRPORT,10025)' 14:38:28 Xecuting 'D CALL^%ZISTCP(XMHOST,XMRPORT) I POP S ER=1 L -^XMBX("TCPCHAN ",XMHOST)' 14:38:28 Xecuting 'S XMHANG="D CLOSE^%ZISTCP"' 14:38:28 Xecuting 'U IO:(DELIMITER=$C(13))' 14:38:28 Look: Timeout=45, Command String='220' 14:38:28 R: 220 14:38:28 Beginning sender-SMTP service 14:38:28 R: sam-desktop ESMTP Postfix (Ubuntu) 14:38:28 S: NOOP 14:38:28 R: 250 2.0.0 Ok 14:38:28 S: HELO MOH.AMMAN.JO 14:38:28 R: 250 sam-desktop 14:38:28 There are no messages in the queue to send 14:38:28 TURN command disabled for 127.0.0.1 14:38:28 S: QUIT 14:38:28 R: 221 2.0.0 Bye 14:38:28 Xecuting 'L -^XMBX("TCPHAN",XMHOST) K XMSIO' 14:38:28 Returning to script 'TOGMAIL'. 14:38:28 Script complete. 14:38:28 0 sent, 0 received.

Now, it's time to send an email from VISTA. Turn off the filer first because we want to send the message ourselves.

Select Manage Mailman Option: local Delivery Management

Active Users/Deliveries Report CHECK background filer Compile Response Time Statistics Deliveries by Group Delivery Queue Statistics Collection Edit numbers to Normalize Reports Graphics Download (TAB separators) Log Response Time Toggler Mail Delivery Statistics Report New Messages and Logon Statistics START background filer STOP background filer

Select Local Delivery Management Option: stop background filer Are you sure you want the Background Filers to stop delivering mail? No// YES

<< Background Filers will stop soon. >>

Now send the email.

 Good afternoon STAR You last signed on today at 14:12

PSM   Pharmacy Data Management ...   PCE    PCE Coordinator Menu ...   HS     Health Summary Coordinator's Menu ...   VFM    VOE Fileman ...   ADM    Admission Clerk Menu ...   CAC    CPRS Configuration (Clin Coord) ...   CLIN   Clinic Clerk Menu ...   CRM    Reminder Managers Menu ...   OP     Outpatient Pharmacy Manager ...   PIMS   PHH - PIMS Main Menu ...   TIUI   TIU Maintenance Menu ...   TIUM   Text Integration Utilities (MIS Manager) ...   WARD   Ward Clerk Menu ...          Medication Administration Menu Pharmacy ...          Physician Menu ...          Rad/Nuc Med Total System Menu ...

Select Core Applications Option: MM MailMan Menu

VA MailMan 8.0 service for HABIEL.SAM_M@MOH.AMMAN.JO You last used MailMan: 05/18/11@14:12 You have no new messages.

NML   New Messages and Responses RML   Read/Manage Messages SML   Send a Message Query/Search for Messages AML   Become a Surrogate (SHARED,MAIL or Other) Personal Preferences ...         Other MailMan Functions ...          Help (User/Group Info., etc.) ...

Select MailMan Menu Option: SML Send a Message

Subject: Hello World from VISTA You may enter the text of the message...

[ WRAP ]==[ INSERT ]=======< Hello World from VISTA >======[ <PF1>H=Help ]==== Test Test Test.

<=======T=======T=======T=======T=======T=======T=======T=======T=======T>======

Send mail to: HABIEL,SAM M// sam.habiel@example.org 127.0.0.1 via 127.0.0.1 And Send to:

Select Message option: Transmit now// Sending [1056]... Sent

This time go back to Transmission Management, and play the script:

<pre style="padding:1em;border:1px dashed #2f6fab;color:black;background-color:#f9f9f9;line-height:1.1em"> Select Transmission Management Option: play a script Select DOMAIN NAME:   127.0.0.1                       1 msgs

Task 7689 is scheduled to transmit this domain's messages on 5/18/2011@14:44:31. Do you want to kill task 7689 before we play the script? No// y YES

# Script Name              Type      Priority -- ---                      1  TOGMAIL                  TCPCHAN    1

14:44:39 To 127.0.0.1 from MOH.AMMAN.JO on 5/18/2011 14:44:39 Script: TOGMAIL 14:44:39 O H="127.0.0.1",P=TCP/GTM 14:44:39 Channel opened to 127.0.0.1 14:44:39 Device 'NULL', Protocol 'TCP/GTM' (file 3.4) 14:44:39 C TCPCHAN-SOCKET10025/GTM 14:44:39 Calling script 'TCPCHAN-SOCKET10025/GTM' (file 4.6) 14:44:39 Xecuting 'L +^XMBX("TCPCHAN",XMHOST):99 E S ER=1,XMER="CHANNEL IN USE" ' 14:44:39 Xecuting 'S X="ERRSCRPT^XMRTCP",@^%ZOSF("TRAP")' 14:44:39 Xecuting 'S XMRPORT=$G(XMRPORT,10025)' 14:44:39 Xecuting 'D CALL^%ZISTCP(XMHOST,XMRPORT) I POP S ER=1 L -^XMBX("TCPCHAN ",XMHOST)' 14:44:39 Xecuting 'S XMHANG="D CLOSE^%ZISTCP"' 14:44:39 Xecuting 'U IO:(DELIMITER=$C(13))' 14:44:39 Look: Timeout=45, Command String='220' 14:44:39 R: 220 14:44:39 Beginning sender-SMTP service 14:44:39 R: sam-desktop ESMTP Postfix (Ubuntu) 14:44:39 S: NOOP 14:44:39 R: 250 2.0.0 Ok 14:44:39 S: HELO MOH.AMMAN.JO 14:44:39 R: 250 sam-desktop 14:44:39 S: MAIL FROM:<HABIEL.SAM_M@MOH.AMMAN.JO> 14:44:39 R: 250 2.1.0 Ok 14:44:39 S: RCPT TO:<sam@AAAAAAA.ORG> 14:44:39 R: 250 2.1.5 Ok 14:44:39 S: DATA 14:44:39 R: 354 End data with <CR><LF>.<CR><LF> 14:44:39 S: Subject: lskdjfksdf 14:44:39 S: Date: 18 May 2011 14:44:31 -0600 (CST) 14:44:39 S: Message-ID: <1058.3110518@MOH.AMMAN.JO> 14:44:39 S: From: <HABIEL.SAM_M@MOH.AMMAN.JO> 14:44:39 S: To: sam@AAAAAAA.ORG 14:44:39 S: 14:44:39 S: lksjdflkjsd 14:44:39 S:. 14:44:40 R: 250 2.0.0 Ok: queued as D8296840557 14:44:41 TURN command disabled for 127.0.0.1 14:44:41 S: QUIT 14:44:41 R: 221 2.0.0 Bye 14:44:41 Xecuting 'L -^XMBX("TCPHAN",XMHOST) K XMSIO' 14:44:41 Returning to script 'TOGMAIL'. 14:44:41 Script complete. 14:44:41 1 sent, 0 received.

We can see that the script played a complete smtp send. So we know stuff worked.

Turn your background filer on and enjoy sending emails from VISTA!

Receiving
While you can expose your VISTA system to the outside world, it is better to have email go through your own mail server and then be relayed to VISTA. Either way, the VISTA set-up is the same.

I have a domain name that is linked to my ip address through dynamic DNS. So I opened port 25 on my router and had it forwarded to the machine hosting VISTA on port 25 on the machine. So if I send email to my domain from Gmail, it reaches VISTA.

Set-up a xinetd listener to forward requests on port 25 (or another port, if you are forwarding email to VISTA from a mail server) to a script that sets up GT.M and calls.

<pre style="padding:1em;border:1px dashed #2f6fab;color:black;background-color:#f9f9f9;line-height:1.1em"> sudo cat vista_pocn-moh_mm_port25 service vista-mm {       disable = no        port = 25 socket_type = stream protocol = tcp user = sam server = /bin/bash groups = yes server_args = /home/sam/pocn-moh/mm_rpcproc type = UNLISTED wait = no       }

<pre style="padding:1em;border:1px dashed #2f6fab;color:black;background-color:#f9f9f9;line-height:1.1em"> sam@sam-desktop:~/pocn-moh$ cat mm_rpcproc cd /home/sam/pocn-moh export gtm_dist=/opt/fis-gtm/V5.4-002A/utf8/ export gtmroutines="uo(routines) $gtm_dist" export gtmgbldir=mumps.gld export PATH=$PATH:$gtm_dist export gtm_chset=utf-8 export gtm_icu_version=4.2 export gtm_badchar=0 date>>rpc_log.log $gtm_dist/mumps -run GTMLNX^XMRUCX 2>> rpc_log.log exit 0
 * 1) !/bin/bash

Stop xinetd and start it in debug mode:

<pre style="padding:1em;border:1px dashed #2f6fab;color:black;background-color:#f9f9f9;line-height:1.1em"> sam@sam-desktop:/etc/xinetd.d$ sudo service xinetd stop * Stopping internet superserver xinetd                                 [ OK ] sam@sam-desktop:/etc/xinetd.d$ sudo xinetd -d

Make sure you see this line to indicate that your service started.

<pre style="padding:1em;border:1px dashed #2f6fab;color:black;background-color:#f9f9f9;line-height:1.1em"> 11/5/18@13:06:29: DEBUG: 6623 {cnf_start_services} Started service: vista-mm

Check netstat -tnlp to see that your port is open.

<pre style="padding:1em;border:1px dashed #2f6fab;color:black;background-color:#f9f9f9;line-height:1.1em"> sam@sam-desktop:~$ netstat -tnlp (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address          Foreign Address         State       PID/Program name tcp       0      0 0.0.0.0:9200            0.0.0.0:*               LISTEN      - tcp       0      0 0.0.0.0:9201            0.0.0.0:*               LISTEN      - tcp       0      0 0.0.0.0:9270            0.0.0.0:*               LISTEN      - tcp       0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      - tcp       0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      - tcp       0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      - tcp       0      0 0.0.0.0:8001            0.0.0.0:*               LISTEN      - tcp       0      0 0.0.0.0:9250            0.0.0.0:*               LISTEN      - tcp       0      0 0.0.0.0:10025           0.0.0.0:*               LISTEN      - tcp       0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      - tcp       0      0 0.0.0.0:9260            0.0.0.0:*               LISTEN      - tcp       0      0 0.0.0.0:9100            0.0.0.0:*               LISTEN      - tcp6      0      0 :::80                   :::*                    LISTEN      - tcp6      0      0 :::22                   :::*                    LISTEN      - tcp6      0      0 ::1:631                 :::*                    LISTEN      - tcp6      0      0 :::443                  :::*                    LISTEN      - tcp6      0      0 :::5900                 :::*                    LISTEN      1472/vino-server

Now, to actually send an email message. First, find a real email address in VISTA. I do that by going to my Mailman account on VISTA and see what my address is.

<pre style="padding:1em;border:1px dashed #2f6fab;color:black;background-color:#f9f9f9;line-height:1.1em"> Good afternoon STAR You last signed on yesterday at 16:22

PSM   Pharmacy Data Management ...   PCE    PCE Coordinator Menu ...   HS     Health Summary Coordinator's Menu ...   VFM    VOE Fileman ...   ADM    Admission Clerk Menu ...   CAC    CPRS Configuration (Clin Coord) ...   CLIN   Clinic Clerk Menu ...   CRM    Reminder Managers Menu ...   OP     Outpatient Pharmacy Manager ...   PIMS   PHH - PIMS Main Menu ...   TIUI   TIU Maintenance Menu ...   TIUM   Text Integration Utilities (MIS Manager) ...   WARD   Ward Clerk Menu ...          Medication Administration Menu Pharmacy ...          Physician Menu ...          Rad/Nuc Med Total System Menu ...

Select Core Applications Option: MM MailMan Menu

VA MailMan 8.0 service for HABIEL.SAM_M@MOH.AMMAN.JO You last used MailMan: 05/17/11@16:22 You have no new messages.

NML   New Messages and Responses RML   Read/Manage Messages SML   Send a Message Query/Search for Messages AML   Become a Surrogate (SHARED,MAIL or Other) Personal Preferences ...         Other MailMan Functions ...          Help (User/Group Info., etc.) ...

Select MailMan Menu Option:

So my email address is. Nice. Let's see if I can send myself an email. Text in bold are my commands to VISTA.

<pre style="padding:1em;border:1px dashed #2f6fab;color:black;background-color:#f9f9f9;line-height:1.1em"> sam@sam-desktop:~/pocn-moh$ telnet localhost 25 Trying ::1... Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 MOH.AMMAN.JO MailMan 8.0 ready HELO SAM.EXAMPLE.COM 250 OK MOH.AMMAN.JO [8.0,DUP,SER,FTP] MAIL FROM:<sam.habiel@example.com> 250 OK Message-ID:1055@MOH.AMMAN.JO RCPT TO:<HABIEL.SAM_M@MOH.AMMAN.JO> 250 'RCPT' accepted DATA 354 Enter data <b>From: Outside Sam <sam.habiel@example.com> To: VISTA Sam <HABIEL.SAM_M@MOH.AMMAN.JO> Date: May 18 2011 Subject: Hello VISTA

Hello VISTA. This is an external message going to VISTA. .</b> 250 'data' accepted QUIT 221 MOH.AMMAN.JO Service closing transmission channel Connection closed by foreign host.

You should see this in xinetd:

<pre style="padding:1em;border:1px dashed #2f6fab;color:black;background-color:#f9f9f9;line-height:1.1em"> 11/5/18@13:17:27: DEBUG: 6623 {server_start} Starting service vista-mm 11/5/18@13:17:27: DEBUG: 6623 {main_loop} active_services = 7

Here's the message in VISTA:

<pre style="padding:1em;border:1px dashed #2f6fab;color:black;background-color:#f9f9f9;line-height:1.1em"> Subj: Hello VISTA [#1055] May 18 2011  1 line From: Outside Sam <sam.habiel@example.com> In 'IN' basket. Page 1 *New* --- Hello VISTA. This is an external message going to VISTA.

Enter message Action (in IN basket): Ignore//

Good. So now we have it. Bear in mind though that in real life, you need to tell email coming from Google or Yahoo that @EXAMPLE.COM needs to go to a specific IP address through an MX Domain Record. Also, you need to tell VISTA that its Domain is EXAMPLE.COM so it receives the messages instead of tossing them away.