OS2 World Community Forum
OS/2, eCS & ArcaOS - Technical => Programming => Topic started by: Per E. Johannessen on May 03, 2019, 04:07:06 pm
-
Hi,
I'd like to automate sending e-mails with a file attached from an application I've created with VX-Rexx. Since I have no experience using Rexx Sockets I'd appreciate help/ sample of how to:
Initialize sockets
Log-in to smtp server
Attach file
Send message
-
PMMail has the PMMSEND utility to do things like that.
-
Hi Per
No idea myself - but if I need to know I would start looking in Rexx Tips and Tricks Version 3.60 which informs me there are/were various libraries available to help with connectivity.
Maybe this rxsock INF file will be of help http://hobbes.nmsu.edu/download/pub/os2/dev/rexx/rxsock.zip
Regards
Pete
-
You can also look at how Marcus de Geus did that in RexxMail. IIRC, attachments have to be base64-encoded, but I don't know how they are appended to the message text.
It looks like a lot of work, so using PMMail or one of the older Mozilla add-ons might be easier.
-
IIRC, attachments have to be base64-encoded,[Not true, even for old-school SMTP.
but I don't know how they are appended to the message text.
Please take a look at MIME.
RXHELO which utilises RXSOCK is a good starting point, but nowadays authentication features should be considered unless you're running an MTA for in-house operations.
-
For now I think I'll go for the PMMSEND utility.
Still, I'd like to learn how do it with RxSock.
"RXHELO which utilises RXSOCK is a good starting point"
Is RXHELO a library?
Or do you mean RXHELO as a term for the connection/authentication commands between the client and the smtp server?
Found somewhere a link to rxhelo.cmd, but unfortunately the link was not available anymore.
-
I've found another example written in REXX: John Small's ReleaseTool.cmd of FM/2. See the fm2/trunk source directory. It's much shorter than RexxMail.cmd, but regarding emails, it's only able to send them.
-
Found somewhere a link to rxhelo.cmd, but unfortunately the link was not available anymore.
Have you tried that link on www.archive.org ? Maybe the target of that link is saved there.
-
Found somewhere a link to rxhelo.cmd, but unfortunately the link was not available anymore.
Have you tried that link on www.archive.org ? Maybe the target of that link is saved there.
It took me to an "archive-site" but got msg that it was unavailable
-
I've found another example written in REXX: John Small's ReleaseTool.cmd of FM/2. See the fm2/trunk source directory. It's much shorter than RexxMail.cmd, but regarding emails, it's only able to send them.
Logged in but still I get "no permission" when I try to read the file.
-
I just did this myself.
Get Weasel and the extra tool qmail. Qmail.cmd is a rexx script to send e-mails. It uses Weasel to actually send. I'm also using STunnel to do the SSL because my ISP requires secure e-mail.
-
It's not SMTP, but my IMAPADD script demonstrates how to use IMAP via REXX to add a message to the remote mail server.
http://www.altsan.org/programming/rexx/index.html#imapadd
I used to use it to have PMMail copy all incoming messages to my IMAP account.
-
I've found another example written in REXX: John Small's ReleaseTool.cmd of FM/2. See the fm2/trunk source directory. It's much shorter than RexxMail.cmd, but regarding emails, it's only able to send them.
Logged in but still I get "no permission" when I try to read the file.
You seem to have tried the trac browser on netlabs.org. It works in some cases, but never for .cmd files. Browsing works reliable via this URL: http://svn.netlabs.org/repos/fm2/trunk/ (http://svn.netlabs.org/repos/fm2/trunk/)
For both trac and the web server browser, you don't have to log in.
-
Have found various "rexx-sendmail-programs" but none of them can be used since they don't support SSL.
Tried PMMail, which receives mail ok, but unable to send. It has lots of configuration options so most likely
I have not set it up right, (so can't use PMMSEND for now).
(Smtp configuration in Seamonkey is easy and works fine.)
Some more searching lead me to:
https://sourceforge.net/projects/rexxcurl/files/rexxcurl/2.0/rexxcurl20os2_RexxTrans.zip/download
Seems like rexxcurl supports SSL and is the right tool.
-
Perhaps pipe through stunnel? http://hobbes.nmsu.edu/download/pub/os2/apps/internet/misc/stunnel-4.05-os2.zip (http://hobbes.nmsu.edu/download/pub/os2/apps/internet/misc/stunnel-4.05-os2.zip)
-
Have found various "rexx-sendmail-programs" but none of them can be used since they don't support SSL.
Tried PMMail, which receives mail ok, but unable to send. It has lots of configuration options so most likely
I have not set it up right, (so can't use PMMSEND for now).
(Smtp configuration in Seamonkey is easy and works fine.)
Some more searching lead me to:
https://sourceforge.net/projects/rexxcurl/files/rexxcurl/2.0/rexxcurl20os2_RexxTrans.zip/download
Seems like rexxcurl supports SSL and is the right tool.
PMMail is tricky to set up. Doug bissett helped me with my setup. I made four pics to show how mine is setup.
Try using the same local port numbers I use for secure poxy. See how these same numbers are used under the Send and Receive Tabs.
-
2David Graser: REXXCURL is an interface to cURL, and cURL is for HTTP (including https). How could it
help with SMTP over SSL?
As far as I can see, newer versions of PMMail use stunnel for SMTP over SSL. So, we could use it too
for the same purpose.
-
It's not SMTP, but my IMAPADD script demonstrates how to use IMAP via REXX to add a message to the remote mail server.
http://www.altsan.org/programming/rexx/index.html#imapadd
I used to use it to have PMMail copy all incoming messages to my IMAP account.
So, PMMail already can use IMAP, instead of POP3??? Your script should write an email message into
an IMAP folder. But how could it help with sending emails with SMTP?
-
Thanks David, I tried various port settings and the following works:
Channel definition Outgoing: Server port 465 and Local port 7587
Account settings SEND: Port 587
If I leave "Allow non-secure" unchecked I get a warning; There is no secure Authentication method available for the SEND server.
When checked there is no warning. In both cases it sends the e-mail.
The option "Use secure channel (SSL) is grayed out, so stlll something is wrong.
-
IIRC, attachments have to be base64-encoded, but I don't know how they are appended to the message text.
MIME headers and body in a single message text file: https://stackoverflow.com/questions/23340291/attachments-not-recognized-despite-base64-being-sent-in-header (https://stackoverflow.com/questions/23340291/attachments-not-recognized-despite-base64-being-sent-in-header). No Rexx sample code, but you should be able to recognize all required parts while viewing a sample text message with an editor or by using a raw e-mail view mode.
IIRC there's a BASE64 encoder written in Rexx ("ENBASE64.CMD"). Albeit you may want to avoid excessive file-I/O, to avoid running out of shared memory more frequently when the Object Rexx interpreter is in use.
If you need some level of control when external EXEs like MAILTO.EXE and some ENBASE64.EXE are in use, then using a BCC header could be an option to verify that sizes and numbers sent e-mails are matching expectations. If the source code of an e-mailing EXE is available, then a Rexx DLL could be an option too. A BASE64 Rexx DLL function may already exist. If not, then writing that component should be easier than writing an e-mailing Rexx DLL.
-
IIRC there's a BASE64 encoder written in Rexx ("ENBASE64.CMD").
A few candidates at Hobbes, to take care of that part: BASE64.ZIP (Rexx CMD file(s)), or Kiewitz' XtraRexx v0.44b (Rexx DLL file).
-
It's not SMTP, but my IMAPADD script demonstrates how to use IMAP via REXX to add a message to the remote mail server.
http://www.altsan.org/programming/rexx/index.html#imapadd
I used to use it to have PMMail copy all incoming messages to my IMAP account.
So, PMMail already can use IMAP, instead of POP3???
Well, sort of, but only with this script (and only to copy messages to an IMAP account).
Your script should write an email message into an IMAP folder.
Maybe I'll try extending it to do that some day.
But how could it help with sending emails with SMTP?
It doesn't, directly. But part of the original question was asking for code to demonstrate how to initialize/use TCP/IP sockets from REXX.
-
Just an update; a kind soul has provided code that works using REXXCURL.