Jump to content

Run remote script with mail


Recommended Posts

Hello to all,

mad idea but can work:

Want to run remote script on my 'server'; but my server must listening with email client.

Is possible to build a simple email client with Autoit ?

Need only to receive object list, with keywords can be simple run other things.

Can anyone help me?

Thank you

M.

Link to comment
Share on other sites

Dear Rudi, you're refferring to the wrong RFC and the wrong function. Sorry. The right RFC is http://www.ietf.org/rfc/rfc1939.txt (SMTP = send email, POP3 = receive) I've done alot of POP3 work, so I decided to write an example for you (not tested by the way, but should work)

Example of POP3 usage in AutoIt:

TCPStartUp()

$user = "your username on the pop3 server goes here"
$pass = "your password goes here"

;connect
$sock = TCPConnect(TCPNameToIP("mail.yourdomain.com"), 110)
If $sock = -1 Then Exit MsgBox(48, "Error", "Couldn't connect to POP3 server!")

;reveice inital response
Do
  $data = TCPRecv($sock, 1024)
Untill $data <> ""
;Verify data for +OK or -ERR - todo

;send username
TCPSend($sock, "USER " & $user & @CRLF)
Do
  $data = TCPRecv($sock, 1024)
Untill $data <> ""
;Verify data for +OK or -ERR - todo

;send password
TCPSend($sock, "PASS " & $pass & @CRLF)
Do
  $data = TCPRecv($sock, 1024)
Untill $data <> ""
;Verify data for +OK or -ERR - todo

;request number of messages
TCPSend($sock, "STAT" & @CRLF)
Do
  $data = TCPRecv($sock, 1024)
Untill $data <> ""
;Verify data for +OK or -ERR - todo

;parse response
$data = StringSplit($data, " ")

If IsArray($data) and $data[0] > 1 and StringIsInt($data[2]) Then
$numbermessages = $data[2]
  MsgBox(32, "Mail Example", "There are " & $numbermessages & " messages in your POP3 box!")
Else
  MsgBox(48, "Mail Example", "Unexpected response from mailserver!")
EndIf

TCPSend($sock, "QUIT" & @CRLF)
TCPCloseSocket($sock)
TCPShutDown()
Exit
Edited by TomZ
Link to comment
Share on other sites

TomZ,

sorry i miss your post (write reply in same time)

Your script return number of mail, is good start, but my goal is buld mini-client to read

only few informations (sender, object).

My idea is to send an email to my home pc and do some task

(mad idea here)

thank you for script and info,

thank to rudi too, you reply is funny :)

m.

Link to comment
Share on other sites

I'd like to give you a hint on adapting my script to actually receive email's. I believe you should use TCPSend($sock, "RETR message_number" & @CRLF);

This will then start outputting the contents of the message with the number you sent to the server, ending with a dot. Like so:

Message header

Message header

....

Message body

Message body

....

(Attachments)

. <--- ending dot

Message numbers range from 1 to the number of messages the script gives you.

Other usefull commands may be LIST and DELE.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...