Jump to content

Email Server


Recommended Posts

Is it possible to connect to a POP3 Email server using autoit, my only goal is to retrieve the number of emails and the subjects, so that i can keep a consistently updated list of the emails in my inbox, instead of logging on to check. I know this can easily be done in Python, i would just like to make a small easily distributable little GUI app. Sorry i don't have any code but i have just begun looking into using autoit to accomplish this.

Thanks,

Link to comment
Share on other sites

  • Moderators

i would just like to make a small easily distributable little GUI app

Think you missed that in his explination.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

It shouldn't be tremendously hard..

Although after trying it for a while I can't figure it out. Using Telnet I was able to log into my email server and check/read the emails therein, but everytime I try with AutoIt, it fails.

Check it out.

Here's how I got in with Telnet (this is a real user/pass, feel free to use it for your tests, but I'll be deleting it in a few days). Everything in red is user input, anything else is server output.

telnet mail.therks.com 110

+OK AVG POP3 Proxy Server 7.0.338/7.0.338 [267.10.12]

user autoit@therks.com

+OK Password required.

pass jonbennett

+OK logged in.

list

+OK POP3 clients that break here, they violate STD53.

1 1619

2 1631

.

retr 1

+OK 1619 octets follow.

Return-Path: <krawlie@hotmail.com>

Delivered-To: autoit@therks.com

Received: from localhost (localhost.localdomain [127.0.0.1])

        by cm-ms3.globat.com (Postfix) with ESMTP id E562C7307D9

        for <autoit@therks.com>; Thu, 18 Aug 2005 20:33:25 -0700 (PDT)

Received: from cm-ms3.globat.com ([127.0.0.1])

by localhost (cm-ms3.globat.com [127.0.0.1]) (amavisd-new, port 10024)

with LMTP id 24567-01-46 for <autoit@therks.com>;

Thu, 18 Aug 2005 20:33:25 -0700 (PDT)

Received: from hotmail.com (bay107-dav3.bay107.hotmail.com [64.4.51.75])

        by cm-ms3.globat.com (Postfix) with ESMTP id A12B47307D5

        for <autoit@therks.com>; Thu, 18 Aug 2005 20:33:25 -0700 (PDT)

Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC;

         Thu, 18 Aug 2005 20:33:25 -0700

Message-ID: <BAY107-DAV31AFFA517CA73C479C042A0B50@phx.gbl>

Received: from 64.4.51.220 by BAY107-DAV3.phx.gbl with DAV;

        Fri, 19 Aug 2005 03:33:25 +0000

X-Originating-IP: [64.4.51.220]

X-Originating-Email: [krawlie@hotmail.com]

X-Sender: krawlie@hotmail.com

From: "Saunders Server" <krawlie@hotmail.com>

To: <autoit@therks.com>

Subject: Test Email

Date: Thu, 18 Aug 2005 20:33:05 -0700

X-Priority: 3

X-MSMail-Priority: Normal

X-Mailer: Microsoft Outlook Express 6.00.2900.2180

X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180

X-OriginalArrivalTime: 19 Aug 2005 03:33:25.0413 (UTC) FILETIME=[C1C3F550:01C5A4

6E]

X-Virus-Scanned: amavisd-new at globat.com

X-Antivirus: AVG for E-mail 7.0.338 [267.10.12]

Mime-Version: 1.0

Content-Transfer-Encoding: 7bit

Content-Type: text/plain; format=flowed; charset=iso-8859-1; reply-type=original

This is a test email.

--

No virus found in this incoming message.

Checked by AVG Anti-Virus.

Version: 7.0.338 / Virus Database: 267.10.12/77 - Release Date: 8/18/2005

.

quit

+OK Bye-bye.

Looks pretty simple, no?

So I started with this AutoIt script.

TCPStartup()

$socket = TCPConnect('mail.therks.com', 110)
If $socket = -1 Then Exit MsgBox(0, 'Error', 'Error bad connection')

GuiCreate('Email Test', 400, 200)
$ed = GUICtrlCreateEdit('', 0, 0, 400, 200)
GuiSetState()

While 1
    $gm = GuiGetMsg()

    if $socket > -1 then
        $recv = TCPRecv($socket, 512)
        if @error then
            GuiCtrlSetData($ed, 'Disconnected!', 1)
            $socket = -1
        elseif $recv <> '' Then
            GuiCtrlSetData($ed, $recv & @LF, 1)
        endif
    endif
    
    if $gm = -3 then exit
WEnd

And right away it errors out, saying it can't connect. Any ideas?

*Edit: And yeah I supposed I could just use Telnet through AutoIt, but I'd like to see if I can go it alone.

Edited by Saunders
Link to comment
Share on other sites

instead of

$socket = TCPConnect('mail.therks.com', 110)

try this

$mailserver = "mail.therks.com"
$socket = TCPConnect(TCPNameToIP($mailserver), 25)

i tried your code, it connects to my server (with my modification) but then nothing happens.

i tried waiting for 220 (connected) and then TCPSend($socket, "EHLO localhost") and TCPSend($socket, "help") just for atry. But nothing happens / it retrieves nothing.

If you get this working pls post !!

Edited by forever
Link to comment
Share on other sites

something like this?

Opt("MustDeclareVars", 1)

Global $mail, $i, $disp

TCPStartup()

Global $socket = TCPConnect(TCPNameToIP('mail.therks.com'), 110)
If $socket = -1 Then Exit MsgBox(0, 'Error', 'Error bad connection')

GuiCreate('Email Test', 400, 200)
Global $ed = GUICtrlCreateEdit('', 0, 0, 400, 200)
GuiSetState()

While 1
    Global $gm = GuiGetMsg()
    if $socket > -1 then
        Global $recv = TCPRecv($socket, 512)
        if @error then
            GuiCtrlSetData($ed, 'Disconnected!', 1)
            $socket = -1
        elseif $recv <> '' Then
            GuiCtrlSetData($ed, $recv, 1)
            If StringInStr($recv, "Hello") Then 
                TCPSend($socket, 'user autoit@therks.com' & @LF)
                GuiCtrlSetData($ed, 'SEND: user autoit@therks.com' & @CRLF, 1)
            EndIf
            If StringInStr($recv, "password") Then 
                TCPSend($socket, 'pass jonbennett' & @LF)
                GuiCtrlSetData($ed, 'SEND: pass jonbennett' & @CRLF, 1)
            EndIf
            If StringInStr($recv, "logged") Then 
                TCPSend($socket, 'list' & @LF)
                GuiCtrlSetData($ed, 'SEND: list' & @CRLF, 1)
            EndIf
            If StringInStr($recv, "POP3") Then
                $mail = StringSplit($recv, @LF)
                $disp = "Count: " & $mail[0] & @CR
                For $i = 1 to $mail[0]
                    $disp &= $mail[$i]
                Next
                MsgBox(0, "mail", $disp)
                TCPSend($socket, 'retr 1' & @LF)
                GuiCtrlSetData($ed, 'SEND: retr 1' & @CRLF, 1)
            EndIf
        endif
    endif
    
    if $gm = -3 then
        TCPSend($socket, 'quit' & @LF)
        TCPCloseSocket($socket)
        exit
    EndIf
WEnd

Can be made more efficient, but it works.

Edited by Dickb
Link to comment
Share on other sites

Actually it doesn't seem to work.. not for me.

It connects alright, I don't get an error, but it never reads the email. Thanks for getting it to connect though, I'll play around with it and see what I can get working.

Edit: Something I wanted to add, I have a virus scanner called AVG, I can't seem to get it disabled without completely uninstalling it, I'm wondering if that first return line is the same as what you guys are getting?

Does it actually say "+OK AVG POP3 Proxy Server 7.0.338/7.0.338 [267.10.13]" ?? I'm wondering if my antivirus is interfering with it and adding that AVG in there.

Edited by Saunders
Link to comment
Share on other sites

Just copied and pasted the code from the board and ran it.

Only get a popup from my firewall, but that is ok.

This is what I see in the 'Email test' edit box:

+OK Hello there.

SEND: user autoit@therks.com

+OK Password required.

SEND: pass jonbennett

+OK logged in.

SEND: list

+OK POP3 clients that break here, they violate STD53.

1 1619

2 1631

.

- Indeed, the first line is different.

I am using Antivir as virus scanner. Maybe that is the difference in the first line.

Try changing

If StringInStr($recv, "Hello") Then

with

If StringInStr($recv, "Proxy") Then

and see if that works.

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...