Sending emails
16 posts
• Page 2 of 2 • 1, 2
Re: Sending emails
Brian wrote a script which sends emails. We use it in DFS. I think it us available from GIT. It works very well
I will dig out the details for you
I will dig out the details for you
- crishog
- Posts: 61
- Joined: Mon Jan 25, 2010 9:52 am
Re: Sending emails
Hi Jinny!
The utility that Chris is referring to is my SMTP class. It's in use in several applications including DFS, the Problem Solving Competition website, and the Dyalog User Meeting registration website. It can be found at https://github.com/Dyalog/SMTP. It's quite function and we're currently working on adding more documentation and examples and also generating "proper" releases.
For now, to use it
rc is the return code, 0 indicates there was no error.
msg is a (hopefully) descriptive diagnostic message if there was an error
Server is an instance of the SMTP class that can be used to send subsequent emails.
If you look at the comments in SendMail, you'll see some examples.
I hope this helps!
/Brian
The utility that Chris is referring to is my SMTP class. It's in use in several applications including DFS, the Problem Solving Competition website, and the Dyalog User Meeting registration website. It can be found at https://github.com/Dyalog/SMTP. It's quite function and we're currently working on adding more documentation and examples and also generating "proper" releases.
For now, to use it
- clone the repository (for this example, let's say you clone it to c:\git\SMTP)
- since you're running MiServer, copy the files from c:\git\SMTP\APLSource\ to the Code folder of your MiSite. This will ensure that the SendMail function and SMTP class are loaded when your MiSite starts
- now, from your application code, you can do something like (using the data from your previous example):
- Code: Select all
Subj←'order'
Body←'send me 100 copies'
From←'annabelnotospam@s-k-y.com'
To←'jinnynotospam@s-k-y.com'
ServerAddr←'smtp.s-k-y.com' ⍝ you'll need to set the proper SMTP server address
(rc msg Server)←ServerAddr SendMail To Subj Body
rc is the return code, 0 indicates there was no error.
msg is a (hopefully) descriptive diagnostic message if there was an error
Server is an instance of the SMTP class that can be used to send subsequent emails.
If you look at the comments in SendMail, you'll see some examples.
I hope this helps!
/Brian
-
Brian|Dyalog - Posts: 120
- Joined: Thu Nov 26, 2009 4:02 pm
- Location: West Henrietta, NY
Re: Sending emails
Got there before me Brian - and probably with better detail than I would have given.
Did you ever write a IMAP client? Just as a matter of interest
Did you ever write a IMAP client? Just as a matter of interest
- crishog
- Posts: 61
- Joined: Mon Jan 25, 2010 9:52 am
Re: Sending emails
Hi Chris!
I have started an IMAP client utility. It needs some work yet, but it was sufficient to accomplish some tasks I had with regard to analyzing bouncebacks and replies from a bulk email transmission. The part that needs the most work is coming up with a DSL (domain specific language) that is easier to use than raw IMAP. My hope is to clean up and properly publish my IMAP, SMTP, and POP3 utilities before the end of the year.
The IMAP and POP3 classes can be found in https://github.com/Dyalog/APLToolsWIP/tree/master/mail. Once I'm happy with the level of functionality, documentation and samples, I'll move them off to their own respective repositories.
Cheers,
/Brian
I have started an IMAP client utility. It needs some work yet, but it was sufficient to accomplish some tasks I had with regard to analyzing bouncebacks and replies from a bulk email transmission. The part that needs the most work is coming up with a DSL (domain specific language) that is easier to use than raw IMAP. My hope is to clean up and properly publish my IMAP, SMTP, and POP3 utilities before the end of the year.
The IMAP and POP3 classes can be found in https://github.com/Dyalog/APLToolsWIP/tree/master/mail. Once I'm happy with the level of functionality, documentation and samples, I'll move them off to their own respective repositories.
Cheers,
/Brian
-
Brian|Dyalog - Posts: 120
- Joined: Thu Nov 26, 2009 4:02 pm
- Location: West Henrietta, NY
Re: Sending emails
Dear Chris and Brian,
Big thanks for your replies, apologies for the delay in coming back to you but it takes me a long time to (fail to) do things as I'm only a basic APL programmer - I last used it in 1992 before the internet!
I couldn't 'clone' from Github as I couldn't work out where to use the http and CLI instructions! I tried command prompt and ScriptFollows and internet with no success!
So I downloaded the zip which gave me two files (SendEmail and SMTP). Unfortunately, wherever I put them, my code doesn't seem to be able to find them. I was able to put SendEmail into my own file of utilities which solved that but can't work out what to do with SMTP. I've tried putting them into my own Code file, into Code/SMTP-main/APLSource, Code/APLSource, and MiServer-master/Utils.
This is my code (from one of the examples in SendEmail)
∇Compose;dd
:Access public
(srv←⎕NS'').(Server Port From Password)←'smtp.aol.com' 465 'blah.blah@aol.com' 'Ainny100!'
Server←3⊃srv #.hh.SendMail '' ⍝ (RUNS OK) create the server instance
(msg←⎕NS'').(To Subj Body)←'blah.blah@sky.com' 'Hello' 'If only!'
Server #.hh.SendMail msg ⍝Errors: '6 VALUE ERROR while creating client'
⍝ The server can be created and message sent in a single call:
Server←3⊃srv #.hh.SendMail msg ⍝ (RUNS OK)
∇
And this is the point in SendEmail which appears to go wrong:
⎕NEW SMTP params
Please, what am I doing wrong?
Big thanks for your replies, apologies for the delay in coming back to you but it takes me a long time to (fail to) do things as I'm only a basic APL programmer - I last used it in 1992 before the internet!
I couldn't 'clone' from Github as I couldn't work out where to use the http and CLI instructions! I tried command prompt and ScriptFollows and internet with no success!
So I downloaded the zip which gave me two files (SendEmail and SMTP). Unfortunately, wherever I put them, my code doesn't seem to be able to find them. I was able to put SendEmail into my own file of utilities which solved that but can't work out what to do with SMTP. I've tried putting them into my own Code file, into Code/SMTP-main/APLSource, Code/APLSource, and MiServer-master/Utils.
This is my code (from one of the examples in SendEmail)
∇Compose;dd
:Access public
(srv←⎕NS'').(Server Port From Password)←'smtp.aol.com' 465 'blah.blah@aol.com' 'Ainny100!'
Server←3⊃srv #.hh.SendMail '' ⍝ (RUNS OK) create the server instance
(msg←⎕NS'').(To Subj Body)←'blah.blah@sky.com' 'Hello' 'If only!'
Server #.hh.SendMail msg ⍝Errors: '6 VALUE ERROR while creating client'
⍝ The server can be created and message sent in a single call:
Server←3⊃srv #.hh.SendMail msg ⍝ (RUNS OK)
∇
And this is the point in SendEmail which appears to go wrong:
⎕NEW SMTP params
Please, what am I doing wrong?
- Jinny
- Posts: 31
- Joined: Sun Jul 01, 2018 10:15 am
Re: Sending emails
FYI
The GITHUB location for Dyalog/SMTP tools is:
https://github.com/Dyalog/SMTP
Click on CODE button, and download the ZIP file.
Extract the two namespace files from ZIP
and place then into your MSERVER Application folder /CODE sub-folder.
You can use SALT or other methods to invoke these 2 namespaces when they are needed.
SMTP.Dyalog
SendMail.Dyalog
The following is a generic example of how to use SMTP to send an email.
This program can be more efficient but it shows the basic steps:
Cheers,
//W
The GITHUB location for Dyalog/SMTP tools is:
https://github.com/Dyalog/SMTP
Click on CODE button, and download the ZIP file.
Extract the two namespace files from ZIP
and place then into your MSERVER Application folder /CODE sub-folder.
You can use SALT or other methods to invoke these 2 namespaces when they are needed.
SMTP.Dyalog
SendMail.Dyalog
The following is a generic example of how to use SMTP to send an email.
This program can be more efficient but it shows the basic steps:
- Code: Select all
R←SENDEMAIL2;srv;Server;msg;From;To;Subj;Body;Port;SendMail;SMTP;clt
⍝ Used to TEST sending an email via SMTP
⍝⍝⍝⍝⍝⍝⍝⍝
⍝ bring in SMTP tools (SendMail and SMTP)
⎕SE.SALT.Load'C:\Software\MSERVER-SMTP-EMAIL\*.dyalog'
⍝ define the client parameters
(clt←⎕NS'').(Server Port From Password)←'sub4.mail.dreamhost.com' 465 'alerts@automatonics.com' 'Secret1234'
⍝ define the message parameters
(msg←⎕NS'').(To Subj Body)←'woodley@brandedoffice.com' 'Hello' 'Hi there!'
⍝ send the mail
(rc msg client log)←clt SendMail msg
⍝ log off the SMTP server
{}client.Logoff
⍝ rc is the return code: 0 means there was no error, non-0 means some error was encountered
⍝ msg is a (hopefully) useful message if there was an error
⍝ client is the instance of SMTP client for the server you specified
⍝ log is the vector of responses from the SMTP server; this is useful for debugging
Cheers,
//W
-
woody - Posts: 146
- Joined: Tue Dec 28, 2010 12:54 am
- Location: Atlanta, Georgia USA
16 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group