Discussion:
Mail file as attachment programically
(too old to reply)
Jeff Smith
2017-01-06 16:27:35 UTC
Permalink
Is it possible to mail a file as an attachment using mail routines. I am using mail$send_add_bodypart, but for some reason the file is appended to the email body not an attachment.
Bob Gezelter
2017-01-06 17:15:36 UTC
Permalink
Post by Jeff Smith
Is it possible to mail a file as an attachment using mail routines. I am using mail$send_add_bodypart, but for some reason the file is appended to the email body not an attachment.
Jeff,

The general answer is yes, although there is some subtlety.

Attachments are not part of the SMTP specification itself, but rather the supplementing MIME RFC. The challenge is not the body itself, but rather the MIME headers that must be included.

A useful approach that I have used (since VMSMAIL knows not from SMTP/MIME headers) is to write a small SMTP client (connecting to the SMTP port on LOCALHOST) and feeding the message (with appropriate headers) into whatever is operating the SMTP service (e.g., MULTINET, TCP/IP Services, TCPWARE).

If I have been unclear, please feel free to contact me (on or off list).

- Bob Gezelter, http://www.rlgsc.com
Jan-Erik Soderholm
2017-01-06 17:21:55 UTC
Permalink
Post by Jeff Smith
Is it possible to mail a file as an attachment using mail routines. I am
using mail$send_add_bodypart, but for some reason the file is appended
to the email body not an attachment.
Google "nbl mail mime vms" and you'll get some pointers to
the NBL utility. You have to create your mail with attachement
first as a plain text file and then send it using NBL.

I usually also sent VMS mails with attachement by first
UU-encoding the binary file and then just mailing it.
Most mail clients interpret an UU-encoded part of a mail
as an attachement.
Craig A. Berry
2017-01-06 18:22:44 UTC
Permalink
Post by Jan-Erik Soderholm
Post by Jeff Smith
Is it possible to mail a file as an attachment using mail routines. I am
using mail$send_add_bodypart, but for some reason the file is appended
to the email body not an attachment.
Google "nbl mail mime vms" and you'll get some pointers to
the NBL utility. You have to create your mail with attachement
first as a plain text file and then send it using NBL.
I usually also sent VMS mails with attachement by first
UU-encoding the binary file and then just mailing it.
Most mail clients interpret an UU-encoded part of a mail
as an attachement.
There are many ways to do this. If you don't mind constructing your own
MIME headers and and message boundaries, you can do it with the SFF
(Send From File) utility and get complete control over the message body
and attachment(s):

$ MCR TCPIP$SYSTEM:TCPIP$SMTP_SFF
Usage: SMTP_SFF infile_name [-log logfile_name] [-loglevel log_level]
infile_name : Name of text input file containing SMTP mail to send.
logfile_name : Name of text log file to log diagnostics to. (Default
SYS$OUTPUT).
log_level : Debug log level. 1 or 0 at this time. (Default 0)

or with the help of UUENCODE:

$ uuencode
ENCODE input-file output-file

or the MIME utility (type HELP MIME)

It's also a question that has been asked and answered many times. The
first two answers I found in a few seconds were:

<http://stackoverflow.com/questions/18923037/send-email-from-openvms>

<https://community.hpe.com/t5/General/send-a-file-as-attachment-in-OpenVMS-mail/td-p/4060125>
Phillip Helbig (undress to reply)
2017-01-07 09:20:08 UTC
Permalink
Post by Jan-Erik Soderholm
I usually also sent VMS mails with attachement by first
UU-encoding the binary file and then just mailing it.
Most mail clients interpret an UU-encoded part of a mail
as an attachement.
Sometimes it works, sometimes it doesn't. Depends on the client.
Outlook doesn't recognize it. Lotus Notes does. Some others do, some
others don't.
Jan-Erik Soderholm
2017-01-07 11:34:37 UTC
Permalink
Post by Phillip Helbig (undress to reply)
Post by Jan-Erik Soderholm
I usually also sent VMS mails with attachement by first
UU-encoding the binary file and then just mailing it.
Most mail clients interpret an UU-encoded part of a mail
as an attachement.
Sometimes it works, sometimes it doesn't. Depends on the client.
Outlook doesn't recognize it....
This gives an attachment in my Office 365 Outlook client (not the
cloud version, a normal local Outlook client).

$ zip somefile.zip somefile.txt
$ mc tcpip$uuencode somefile.zip somefile.uue
$ mail/subj=somefile somefile.uue "smtp%""jan-***@telia.com"""

I have sent all types of files that way. Works every time.
Post by Phillip Helbig (undress to reply)
Lotus Notes does. Some others do, some
others don't.
Dirk Munk
2017-01-06 18:43:31 UTC
Permalink
Post by Jeff Smith
Is it possible to mail a file as an attachment using mail routines. I am using mail$send_add_bodypart, but for some reason the file is appended to the email body not an attachment.
Ye,. it is certainly possible with SFF.

I once wrote a DCL batch procedure that sent off emails with files
attached for a billing application.
Jim
2017-01-06 18:50:01 UTC
Permalink
Post by Jeff Smith
Is it possible to mail a file as an attachment using mail routines. I am using mail$send_add_bodypart, but for some reason the file is appended to the email body not an attachment.
You might find the hack described here

https://groups.google.com/forum/#!searchin/comp.os.vms//comp.os.vms/sbIhKwSOKK8/xOc2tNpPxR4J

interesting/useful.
John Reagan
2017-01-06 21:49:30 UTC
Permalink
Post by Jeff Smith
Is it possible to mail a file as an attachment using mail routines. I am using mail$send_add_bodypart, but for some reason the file is appended to the email body not an attachment.
I routinely use MCR MIME to create attachments that I want to send back to my PC or Mac. Once I create that file, it is just as simple as

$ mail
mail> send my_mime_attachments.txt
to: ***@...
Stephen Hoffman
2017-01-06 23:51:02 UTC
Permalink
Post by Jeff Smith
Is it possible to mail a file as an attachment using mail routines. I
am using mail$send_add_bodypart, but for some reason the file is
appended to the email body not an attachment.
OpenVMS-to-OpenVMS via DECnet, yes.
As for SMTP, you have to provide your own MIME implementation within
the mail API.
The MAIL$ API doesn't know from MIME, either sending or for receiving
and unpacking MIME-format messages.
The SEND/FOREIGN file-sending mechanism within the MAIL utility needs
DECnet end-to-end, and isn't compatible with SMTP.
You can either use the provided MIME utility for creating the
MIME-encoded file, or scrounge your own MIME library and tools and use
that.
There are MPACK ports around, and there are other choices.
--
Pure Personal Opinion | HoffmanLabs LLC
Hunter Goatley
2017-02-25 17:28:00 UTC
Permalink
Post by Stephen Hoffman
The SEND/FOREIGN file-sending mechanism within the MAIL utility needs
DECnet end-to-end, and isn't compatible with SMTP.
Not quite true, as PMDF, MX, MultiNet, and TCPware all support using
MAIL/FOREIGN to send a file as a mail message via SMTP. You can use that
to send any VMS file to another VMS system running any one of those
products while keeping the VMS file attributes intact.

MAIL/FOREIGN/TYPE=1 allows you to send a file to non-VMS systems.

The file is simply base64-encoded and sent as a MIME message that
consists only of the base64-encoded attachment.
--
Hunter
------
Hunter Goatley, Process Software, http://www.process.com/
***@goatley.com http://hunter.goatley.com/
Jan-Erik Soderholm
2017-02-25 18:22:55 UTC
Permalink
Post by Hunter Goatley
Post by Stephen Hoffman
The SEND/FOREIGN file-sending mechanism within the MAIL utility needs
DECnet end-to-end, and isn't compatible with SMTP.
Not quite true, as PMDF, MX, MultiNet, and TCPware all support using
MAIL/FOREIGN to send a file as a mail message via SMTP. You can use that to
send any VMS file to another VMS system running any one of those products
while keeping the VMS file attributes intact.
MAIL/FOREIGN/TYPE=1 allows you to send a file to non-VMS systems.
The file is simply base64-encoded and sent as a MIME message that consists
only of the base64-encoded attachment.
Can you add a subject (I guess so) and some text message body (I hope so).

Mails with an attachment without any text message body usally has a
higher risk of beeing stopped in SAP filters.
Hunter Goatley
2017-02-28 21:26:31 UTC
Permalink
Post by Jan-Erik Soderholm
Can you add a subject (I guess so) and some text message body (I hope so).
Subject yes (using /SUBJECT), but a text message body, no. The /FOREIGN
protocol as implemented by VMS MAIL doesn't allow for that. (You can
pass the file name, but that's all.)
Post by Jan-Erik Soderholm
Mails with an attachment without any text message body usally has a
higher risk of beeing stopped in SAP filters.
True, some filters will stop such things.
--
Hunter
------
Hunter Goatley, Process Software, http://www.process.com/
***@goatley.com http://hunter.goatley.com/
Jan-Erik Soderholm
2017-02-28 23:18:50 UTC
Permalink
Post by Hunter Goatley
Post by Jan-Erik Soderholm
Can you add a subject (I guess so) and some text message body (I hope so).
Subject yes (using /SUBJECT), but a text message body, no. The /FOREIGN
protocol as implemented by VMS MAIL doesn't allow for that. (You can pass
the file name, but that's all.)
What if the file is a ready formatted mail file containing both
a clear text part and one or more MIME encoded attachment(s)?

Will it send that as one complete mail?

Maybe it just sends the whole file as one attachment...
Post by Hunter Goatley
Post by Jan-Erik Soderholm
Mails with an attachment without any text message body usally has a
higher risk of beeing stopped in SAP filters.
True, some filters will stop such things.
V***@SendSpamHere.ORG
2017-03-01 01:48:00 UTC
Permalink
Post by Jan-Erik Soderholm
Post by Hunter Goatley
Post by Jan-Erik Soderholm
Can you add a subject (I guess so) and some text message body (I hope so).
Subject yes (using /SUBJECT), but a text message body, no. The /FOREIGN
protocol as implemented by VMS MAIL doesn't allow for that. (You can pass
the file name, but that's all.)
What if the file is a ready formatted mail file containing both
a clear text part and one or more MIME encoded attachment(s)?
Will it send that as one complete mail?
Maybe it just sends the whole file as one attachment...
Post by Hunter Goatley
Post by Jan-Erik Soderholm
Mails with an attachment without any text message body usally has a
higher risk of beeing stopped in SAP filters.
True, some filters will stop such things.
FWIW, I wrote a command program for a customer years ago. You can send an attachment
(several, if necesary) with a text body. With body and attachments as separate files,
al that's needed is the names of tHe files. MIME types are controlled by the extension
of the file(s).
--
VAXman- A Bored Certified VMS Kernel Mode Hacker VAXman(at)TMESIS(dot)ORG

I speak to machines with the voice of humanity.
Hunter Goatley
2017-03-01 16:28:54 UTC
Permalink
Post by Jan-Erik Soderholm
What if the file is a ready formatted mail file containing both
a clear text part and one or more MIME encoded attachment(s)?
It could have been done that way, but wasn't. Well, not in anything but
MX. MX supports /TYPE=255, allows a person with privileges to resend a
message and maintain the original RFC822 headers (doing what you
suggest). Privileges were required to prevent people from forging mail.
(This was implemented long before most people knew how to spoof mail.)
--
Hunter
------
Hunter Goatley, Process Software, http://www.process.com/
***@goatley.com http://hunter.goatley.com/
Craig A. Berry
2017-03-01 18:21:15 UTC
Permalink
Post by Hunter Goatley
Post by Jan-Erik Soderholm
What if the file is a ready formatted mail file containing both
a clear text part and one or more MIME encoded attachment(s)?
It could have been done that way, but wasn't. Well, not in anything but
MX.
SFF can also do that:

<http://h41379.www4.hpe.com/doc/83final/6526/6526pro_045.html>
Stephen Hoffman
2017-03-01 18:30:27 UTC
Permalink
Post by Craig A. Berry
What if the file is a ready formatted mail file containing both a clear
text part and one or more MIME encoded attachment(s)?
It could have been done that way, but wasn't. Well, not in anything but MX.
<http://h41379.www4.hpe.com/doc/83final/6526/6526pro_045.html>
Ayup. The SFF bits combined with the MIME utility present in recent
OpenVMS, and off the messages can go.

It'd be nice if MAIL integrated MIME support, but we're going to be
using MAIL and SFF and the MIME utility for a while, or using one of
the add-on freeware or other add-ons.
--
Pure Personal Opinion | HoffmanLabs LLC
Hunter Goatley
2017-03-01 19:40:12 UTC
Permalink
Post by Stephen Hoffman
What if the file is a ready formatted mail file containing both a
clear text part and one or more MIME encoded attachment(s)?
It could have been done that way, but wasn't. Well, not in anything but MX.
Right. I was referring specifically to the SEND/FOREIGN/TYPE=xxx options.
Post by Stephen Hoffman
It'd be nice if MAIL integrated MIME support, but we're going to be
using MAIL and SFF and the MIME utility for a while, or using one of the
add-on freeware or other add-ons.
That includes PMDF MAIL, which is a VMS MAIL replacement that supports
MIME messages and lots more that VMS MAIL doesn't do. Basically, it's
what VMS MAIL should have been upgraded to do, but Compaq/HP never did it.
--
Hunter
------
Hunter Goatley, Process Software, http://www.process.com/
***@goatley.com http://hunter.goatley.com/
Arne Vajhøj
2017-03-02 01:38:14 UTC
Permalink
Post by Hunter Goatley
Post by Stephen Hoffman
It'd be nice if MAIL integrated MIME support, but we're going to be
using MAIL and SFF and the MIME utility for a while, or using one of the
add-on freeware or other add-ons.
That includes PMDF MAIL, which is a VMS MAIL replacement that supports
MIME messages and lots more that VMS MAIL doesn't do. Basically, it's
what VMS MAIL should have been upgraded to do, but Compaq/HP never did it.
PMDF was a nice product when I used it (mid 90's).

But I think the ship has sailed. Mail client for VMS is not an important
issue today.

Arne
Scott Dorsey
2017-03-02 02:16:34 UTC
Permalink
Post by Arne Vajhøj
PMDF was a nice product when I used it (mid 90's).
But I think the ship has sailed. Mail client for VMS is not an important
issue today.
Mail client is very important, because you want to have programs send you
mail when there is an issue, and you might want to be able to send programs
mail as well. And you might want to use it as a user directly in order to
send tests and the like.

But... mail clients today aren't much like mail clients were back then
because the client and the MTA may not be running on the same system and
it's expected that one will use pop or imap to talk to the MTA. So whatever
mail client is needed, it's going to be very different from what was used
and needed decades ago.

But it doesn't have to be very sophisticated, and it doesn't have to do
any handling or routing because today that's all the MTA's responsibility.
But it _does_ need to support MIME.
--scott
--
"C'est un Nagra. C'est suisse, et tres, tres precis."
Arne Vajhøj
2017-03-02 02:29:08 UTC
Permalink
Post by Scott Dorsey
Post by Arne Vajhøj
PMDF was a nice product when I used it (mid 90's).
But I think the ship has sailed. Mail client for VMS is not an important
issue today.
Mail client is very important, because you want to have programs send you
mail when there is an issue, and you might want to be able to send programs
mail as well. And you might want to use it as a user directly in order to
send tests and the like.
Yes.

But that does not require a mail client.

It requires something to be able to talk to a SMTP server (on VMS or
on another system).

And that exists today.
Post by Scott Dorsey
But... mail clients today aren't much like mail clients were back then
because the client and the MTA may not be running on the same system and
it's expected that one will use pop or imap to talk to the MTA. So whatever
mail client is needed, it's going to be very different from what was used
and needed decades ago.
Sending mail is SMTP not POP3 or IMAP4.
Post by Scott Dorsey
But it doesn't have to be very sophisticated, and it doesn't have to do
any handling or routing because today that's all the MTA's responsibility.
But it _does_ need to support MIME.
A library that supports MIME is nice.

But MIME email is not rocket science. Sending MIME email via a plain
socket interface is trivial.

Arne
Stephen Hoffman
2017-03-02 16:11:40 UTC
Permalink
Post by Arne Vajhøj
But I think the ship has sailed. Mail client for VMS is not an
important issue today.
Yes, it still is. Less so for folks doing desktop tasks which is what
you're thinking of, but a functional command-line client is still
useful for accessing the files and patches that inevitably still get
mailed around, and also particularly having better APIs for apps. Apps
that need to send and receive and process mail messages and
attachments; notifications, logs, document servers, even full-on
intentional RCEs for the few folks that want to configure that; akin to
DELIVER. But yes, rather lower on the list than many other tasks,
given it's fully possible to write a few hectares of source code to do
this from responsibly-sourced glacial-pristine artisanal bits.
--
Pure Personal Opinion | HoffmanLabs LLC
Arne Vajhøj
2017-03-03 02:13:04 UTC
Permalink
Post by Stephen Hoffman
Post by Arne Vajhøj
But I think the ship has sailed. Mail client for VMS is not an
important issue today.
Yes, it still is. Less so for folks doing desktop tasks which is what
you're thinking of, but a functional command-line client is still useful
for accessing the files and patches that inevitably still get mailed
around, and also particularly having better APIs for apps. Apps that
need to send and receive and process mail messages and attachments;
notifications, logs, document servers, even full-on intentional RCEs for
the few folks that want to configure that; akin to DELIVER. But yes,
rather lower on the list than many other tasks, given it's fully
possible to write a few hectares of source code to do this from
responsibly-sourced glacial-pristine artisanal bits.
Applications does not need a mail client. They need a good mail library.

Emailing patches to systems does not seem like a desirable distribution
strategy to me. And most servers today does not have the ability to
receive email. Somehow they manage to do without. VMS can too.

Arne
Paul Sture
2017-03-03 19:21:42 UTC
Permalink
Post by Stephen Hoffman
Post by Arne Vajhøj
But I think the ship has sailed. Mail client for VMS is not an
important issue today.
Yes, it still is. Less so for folks doing desktop tasks which is what
you're thinking of, but a functional command-line client is still
useful for accessing the files and patches that inevitably still get
mailed around, and also particularly having better APIs for apps. Apps
that need to send and receive and process mail messages and
attachments; notifications, logs, document servers, even full-on
intentional RCEs for the few folks that want to configure that; akin to
DELIVER. But yes, rather lower on the list than many other tasks,
given it's fully possible to write a few hectares of source code to do
this from responsibly-sourced glacial-pristine artisanal bits.
As a case in point, I've got an email in front of me which is the output
of an overnight cron job. This one scans for the bi-weekly image builds
for the SmartOS Global Zone and presents a list of download URLs for
each of the latest USB boot, iso, VMware etc images, all in one
convenient spot. Other cron jobs report on the success or failure of
backup jobs etc etc.

Even the non-appearance of these emails is a trigger that something
is amiss and needs investigating.
--
A supercomputer is a device for turning compute-bound problems into
I/O-bound problems. ---Ken Batcher
Stephen Hoffman
2017-03-03 20:10:13 UTC
Permalink
Post by Paul Sture
As a case in point, I've got an email in front of me which is the
output of an overnight cron job. ...
Even the non-appearance of these emails is a trigger that something is
amiss and needs investigating.
I'm headed toward push notifications and SNMP traps for anything
interesting or important, distributed logging where that fits better
(syslog et al) and starting to retire email status notifications where
that's feasible. But more than a few of the tools I deal with and
maintain still do use email for various purposes including for
statistics and error logging, and the code still slogs through
constructing the necessary MIME and shipping it off via MAIL$, or just
brute-forcing the problem using non-MIME ASCII-encoded text and the
MAIL$ routines.
--
Pure Personal Opinion | HoffmanLabs LLC
o***@gmail.com
2017-02-27 10:49:58 UTC
Permalink
Post by Jeff Smith
Is it possible to mail a file as an attachment using mail routines. I am using mail$send_add_bodypart, but for some reason the file is appended to the email body not an attachment.
Long time ago i wrote a symbiont for this. I am not maintaining it anymore but it shouls till wordk.

You can find it here:

https://www.digiater.nl/openvms/freeware/v80/mailsym/

Oswald
Loading...