Difference between revisions of "Setting Up Mailman For External Email"

From VistApedia
Jump to: navigation, search
Line 2: Line 2:
 
Most people want to send email to the outside world from VISTA. So we will start with that.
 
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,  
+
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. We will to that part in a moment.
 +
 
 +
If you have an unauthenticated SMTP, make an new entry in the Domain file like this, assuming that your SMTP is smtp.example.com.
 +
 
 +
<pre style="padding:1em;border:1px dashed #2f6fab;color:black;background-color:#f9f9f9;line-height:1.1em">
 +
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
 +
</pre>
 +
 
 +
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.
 +
 
 +
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/
 +
 
 +
In that case, your domain will look like this:
 +
 
 +
<pre style="padding:1em;border:1px dashed #2f6fab;color:black;background-color:#f9f9f9;line-height:1.1em">
 +
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
 +
</pre>
 +
 
  
 
==Receiving==
 
==Receiving==
Line 129: Line 172:
 
</pre>
 
</pre>
  
So my email address is <code>HABIEL.SAM_M@MOH.AMMAN.JO</code>. Nice. Let's see if I can send myself an email.
+
So my email address is <code>HABIEL.SAM_M@MOH.AMMAN.JO</code>. 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">
 
<pre style="padding:1em;border:1px dashed #2f6fab;color:black;background-color:#f9f9f9;line-height:1.1em">
Line 165: Line 208:
 
11/5/18@13:17:27: DEBUG: 6623 {main_loop} active_services = 7
 
11/5/18@13:17:27: DEBUG: 6623 {main_loop} active_services = 7
 
</pre>
 
</pre>
 +
 +
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//
 +
</pre>
 +
 +
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 VISTA.COM so it receives the messages instead of tossing them away.

Revision as of 10:47, 18 May 2011

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. We will to that part in a moment.

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.

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/

In that case, your domain will look like this:

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


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 GTMLNX^XMRUCX.

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
        }
sam@sam-desktop:~/pocn-moh$ cat mm_rpcproc
#!/bin/bash
#
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

Stop xinetd and start it in debug mode:

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.

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.

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.

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 HABIEL.SAM_M@MOH.AMMAN.JO. Nice. Let's see if I can send myself an email. Text in bold are my commands to VISTA.

sam@sam-desktop:~/pocn-moh$ <b>telnet localhost 25</b>
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 MOH.AMMAN.JO MailMan 8.0 ready
<b>HELO SAM.EXAMPLE.COM</b>
250 OK MOH.AMMAN.JO [8.0,DUP,SER,FTP]
<b>MAIL FROM:<sam.habiel@example.com></b>
250 OK Message-ID:1055@MOH.AMMAN.JO
<b>RCPT TO:<HABIEL.SAM_M@MOH.AMMAN.JO></b>
250 'RCPT' accepted
<b>DATA</b>
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
<b>QUIT</b>
221 MOH.AMMAN.JO Service closing transmission channel
Connection closed by foreign host.

You should see this in xinetd:

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:

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 VISTA.COM so it receives the messages instead of tossing them away.