One way of sending mail from IGOR
Posted April 29th, 2008 by andyfaff
A quick and direct solution of sending mail is available if you have the base64.xop and SOCKIT files installed, and the server doesn't require secure login. It is also possible to send attachments, but this requires slightly more effort as the attachment needs to be encoded in base64 (which is possible, if I get round to writing it).
Here is some sample code that demonstrates using the SMTP LOGIN protocol (another option may be PLAIN, see http://www.technoids.org/saslmech.html#appA) :
string mailServer = "mail.mymailserver.com" string username = base64encode("myusername") string password = base64encode("mypassword") variable sock //holds the SOCKIT reference make/t buf //holds the output from the SOCKIT connection sock = sockitopenconnection(mailServer,25,buf,"","",1) //open a SOCKIT connection to the mail server sockitsendmsg(sock,"AUTH LOGIN\n") //SMTP LOGIN, NOT VERY SECURE sockitsendmsg(sock,username+"\n") sockitsendmsg(sock,password+"\n") sockitsendmsg(sock,"HELO whatever.whatever.com\n") //say HELO to the server sockitsendmsg(sock,"MAIL FROM: username@mymailserver.com\n") //say who you are sockitsendmsg(sock,"RCPT TO: poo@mymailserver.com\n") //say who the recipient is sockitsendmsg(sock,"DATA\n") //start the message sockitsendmsg(sock,"Subject:test a message\n\n") //subject line, note double newline is required sockitsendmsg(sock,"This is a test message\n") //the message sockitsendmsg(sock,".\n") //finish the message and send sockitcloseconnection(sock) //close the SOCKIT connection

I'm updating this example
I'm updating this example with SockIT operations. Also, some mail servers require CRLF in places, or require HELO before AUTH LOGIN. For example, this format will work for Yahoo mail. For servers that require SSL, like gmail, see http://www.igorexchange.com/node/952.
For some reason, this only works without the /q flag in sockitiopenconnection. Maybe printing output slows Igor down enough to let messages get sent before the socket is closed?
Could one roll it up
Could one roll it up like:
The only trouble is that the server may barf because the whole message arrives at once.