Jump to content

SSL Gmail with OpenSSL


mikeytown2
 Share

Recommended Posts

Sorry if this isn't the correct place to post but I'm receiving errors with this.

Here is the command trace output window -

<RECV> CONNECTED(0000078C)
---
Certificate chain
 0 s:/C=US/ST=California/L=Mountain View/O=Google Inc/CN=smtp.gmail.com
   i:/C=ZA/ST=Western Cape/L=Cape Town/O=Thawte Consulting cc/OU=Certification Services Division/CN=Thawte Premium Server CA/emailAddress=premium-server@thawte.com
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIDVjCCAr+gAwIBAgIDP97OMA0GCSqGSIb3DQEBBAUAMIHOMQswCQYDVQQGEwJa
QTEVMBMGA1UECBMMV2VzdGVybiBDYXBlMRIwEAYDVQQHEwlDYXBlIFRvd24xHTAb
BgNVBAoTFFRoYXd0ZSBDb25zdWx0aW5nIGNjMSgwJgYDVQQLEx9DZXJ0aWZpY2F0
aW9uIFNlcnZpY2VzIERpdmlzaW9uMSEwHwYDVQQDExhUaGF3dGUgUHJlbWl1bSBT
ZXJ2ZXIgQ0ExKDAmBgkqhkiG9w0BCQEWGXByZW1pdW0tc2VydmVyQHRoYXd0ZS5j
b20wHhcNMDUwOTA1MDg1OTAyWhcNMDYwOTA1MDg1OTAyWjBoMQswCQYDVQQGEwJV
UzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzET
MBEGA1UEChMKR29vZ2xlIEluYzEXMBUGA1UEAxMOc210cC5nbWFpbC5jb20wgZ8w
DQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMm+APV2IPBnnqOb5w15LPrpNaCfIDZm
3Z41dg/rmhs7szXCx5oWvW6idYerguXQuw1B0XWKbYLJ9Lbz/kX2k9NpyeNmz0J7
pLLBPoa0djthKfMQzgviWRmvad97JaFWFLxUGabISziA/0s3LB1VWMPX+IcxM0hs
pSzdSzjkoI8LAgMBAAGjgaYwgaMwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUF
BwMCMEAGA1UdHwQ5MDcwNaAzoDGGL2h0dHA6Ly9jcmwudGhhd3RlLmNvbS9UaGF3
dGVQcmVtaXVtU2VydmVyQ0EuY3JsMDIGCCsGAQUFBwEBBCYwJDAiBggrBgEFBQcw
AYYWaHR0cDovL29jc3AudGhhd3RlLmNvbTAMBgNVHRMBAf8EAjAAMA0GCSqGSIb3
DQEBBAUAA4GBACvK1QfluQ26oqabKWaQUauwJQio6t/nRUmaN/cfB3EVeZihxELb
+5a2aD/ljSUNLwEZb/OrG2eXGgnmwGrjERfLJurqYBXQuRwByAQ2lavucv4lgQmU
Qumc3IhN67fNinoOoMa+/KZAYaoBPI8n6t/JR1/q30/rCZ64xKfnqYRf
-----END CERTIFICATE-----
subject=/C=US/ST=California/L=Mountain View/O=Google Inc/CN=smtp.gmail.com
issuer=/C=ZA/ST=Western Cape/L=Cape Town/O=Thawte Consulting cc/OU=Certification Services Division/CN=Thawte Premium Server CA/emailAddress=premium-server@thawte.com
---
No client certificate CA names sent
---
SSL handshake has read 1012 bytes and written 338 bytes
---
New, TLSv1/SSLv3, Cipher is DES-CBC3-SHA
Server public key is 1024 bit
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1
    Cipher  : DES-CBC3-SHA
    Session-ID: 046D2E39751EDBFF61C59797D4F7CA48C189283A3AF0550FBFF4F5F378F1B5D3
    Session-ID-ctx: 
    Master-Key: 44959A49D3F35ACBD80F0A08B63DB0F3B58426D2A8C5C67342CE7E5F3B56BEAF26F13C9F43A36D564642D51524729066
    Key-Arg   : None
    Start Time: 1142534738
    Timeout   : 300 (sec)
    Verify return code: 21 (unable to verify the first certificate)
---
220 mx.gmail.com ESMTP 10sm1784483nzo
<SEND> ehlo OFFICE
<RECV> 250-mx.gmail.com at your service
250-SIZE 20971520
250-8BITMIME
250-AUTH LOGIN PLAIN
250 ENHANCEDSTATUSCODES
<SEND> AUTH LOGIN
<RECV> 334 VXNlcm5hbWU6
<SEND> ZXNxdWliZWwubWlrZUBnbWFpbC5jb20=
<RECV> 334 UGFzc3dvcmQ6
<SEND> ZnVjazEyMzQ=
<RECV> 235 2.7.0 Accepted
<SEND> MAIL FROM: <myemail@gmail.com> --- not what i originally used but you get the idea
<RECV> 250 2.1.0 OK
<SEND> RCPT TO: <myotheremail@domain.com> --- again, not what i originally used...
<RECV> 250 2.1.5 OK
<SEND> DATA
<RECV> 354 Go ahead
<SEND> From:User<myemail@gmail.com>
To:<myotheremail@domain.com>
Subject:UDF Test
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII

Testing the new email udf
Second Line

now the command trace window sort of "Freezes" at that part and then a popup displays...

ERROR!

Got This:0
Was looking for this:250

State:9

Any help appreciated!

Thanks,

PartieHonteuse

Link to comment
Share on other sites

  • Replies 63
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

_ArrayAdd ( $as_Send, "From:" & $s_FromName & "<" & $s_FromAddress & ">" & @CRLF & _
    "To:" & "<" & $s_ToAddress & ">" & @CRLF & _
    "Subject:" & $s_Subject & @CRLF & _
    "Mime-Version: 1.0" & @CRLF & _
    "Content-Type: text/plain; charset=US-ASCII" & @CRLF & _
    @CRLF & $BodyString & _
    @CRLF & @CRLF & "." & @CRLF)
_ArrayAdd ( $as_ReplyCode, "250 ")
This is the part of the code that is giving you trouble. it should be on line 78. anyway its not sending the @CRLF & @CRLF & "." & @CRLF which tells the smtp server that your done sending the email.

So the error code was it didn't get anything back, and it was expecting a 250. I'm not sure why it wouldn't send a

.

but for some reason its not doing that. check the source code to make sure it in there.

Good Luck!

Link to comment
Share on other sites

  • 8 months later...

http://en.wikipedia.org/wiki/Post_Office_Protocol

POP ssl v2 is what you want. You need to mod this part of my code...

Line 36

CODE
;###START_COMMANDS###

Local $as_Send[1] ;command sent to smtp sever

Local $as_ReplyCode[1] ;Return code from SMTP server indicating success 250 334 ect...

_ArrayAdd ( $as_ReplyCode, "+OK")

_ArrayAdd ( $as_Send, "USER " & $User )

_ArrayAdd ( $as_ReplyCode, "+OK")

_ArrayAdd ( $as_Send, "PASS " & $Pass & @CRLF)

_ArrayAdd ( $as_ReplyCode, "+OK")

_ArrayAdd ( $as_Send, "STAT" & @CRLF)

_ArrayAdd ( $as_ReplyCode, "+OK")

_ArrayAdd ( $as_Send, "LIST" & @CRLF)

_ArrayAdd ( $as_ReplyCode, ".")

_ArrayAdd ( $as_Send, "RETR 1" & @CRLF)

_ArrayAdd ( $as_ReplyCode, ".")

_ArrayAdd ( $as_Send, "QUIT" & @CRLF)

;###END_COMMANDS###

Right now all it does is grab the first email and then it quits. To do what you want it to do you need to beable to parce the list to count how many messages there are then make a loop that will go through as many RETR X as needed. Also add a DELE X in the loop.

You also need to mod the "brains" as well

Line 100

CODE
ElseIf StringInStr($temp, $as_ReplyCode[$State_R]) Then

$Read = StdoutRead($RunPID) ;flush buffer

_TraceRun("<RECV> " & $Read )

StdinWrite($RunPID, $as_Send[$State_R])

_TraceRun("<SEND> " & $as_Send[$State_R])

$State_R = $State_R + 1

ExitLoop

As well as the exit condition

Line 116

CODE
If $State_R = UBound($as_ReplyCode) Then

ExitLoop

EndIf

Sleep(50)

From the block of code in line 100:

The $Read variable is what you would use, add that into an array using _ArrayAdd

I hope this helps!

Link to comment
Share on other sites

  • 4 months later...
  • 8 months later...

there s a problem here, :)

can anybody explain, why this script reads a half part of mails ?

Could you please explain your problem in more details? This script is mainly a proof of concept, it works but it's far from complete.
Link to comment
Share on other sites

Could you please explain your problem in more details? This script is mainly a proof of concept, it works but it's far from complete.

nvm i solved my problem :) , ty for this script.

EDIT: i have another problem, :blink:

EDIT : nvm solved again :P

Edited by mistakilla

:alien: ~ Every Living Thing is a Code Snippet of World Application ~ :alien:

Link to comment
Share on other sites

  • 9 months later...

Updated first post with a new version that works with v3.2.12.0 and up. Ptrex was interested in this so I did some ugly hacks to get it working again. If there is some interest, I am willing to give this another go; as in make the core code more usable.

This new code might stall and sit there and do nothing because I took out my buffer flushes.

Link to comment
Share on other sites

@mikeytown2

OK here's my story so far.

I have been trying to get to read my Gmails through AU3.

Ran into a lot of threads that offered the functionality. But non of them worked (in the beginning).

After some great help of "Mikeytown2" I got the ball rolling.

What where my problems I ran into :

- First of all I had a bugged version of OPENSSL.EXE !!

This a good working version Win32OpenSSL_Light-0_9_8i.exe : See first post for download link.

- Secondly never install a new OPENSSL version over an old one.

Deinstall the old version -> reboot and reinstall the new version is the safest way to go.

- Thirdly. I had a firewall issues which blocked ports like 995 and 465.

If you want to make sure it runs OK. Use this test command :

c:\openssl\bin\openssl s_client -crlf -ign_eof -connect smtp.gmail.com:465

Edit :

Version POP 2.1 DOES works (if you run it with the Beta Release of Au3 of course !!)

My mistake.

Thanks again for your support.

Regards,

ptrex

Edited by ptrex
Link to comment
Share on other sites

@mikeytown2

I have been doing lost of tests over the weekend.

And I must say IT DOES WORK both ways !!

Just fantastic.

I know this thread is 2 year old.

But it deserves more attention.

Regards,

ptrex

Edited by ptrex
Link to comment
Share on other sites

I'll try and make it into a UDF. That means functions to call, fun stuff like that. Give me a couple of days and I should have something workable. Working on SMTP first

So I hope to have these functions be public

_SMTP_Connect

_SMTP_Login

_SMTP_SendEmail

_SMTP_Disconnect

And here would be some private functions

_SMTP_ReadBuffer

_SMTP_ChkForCode

_SMTP_WriteBuffer

It would probably have a Global Variable called

$_SMTP_RunPID

Probably use error codes and put the burden of checking then on the end user.

I'm kinda surprised no one has done this yet... it ain't that hard!

btw POP 2.1 doesn't flush the buffer so you can miss part of the email if its fairly large.

Link to comment
Share on other sites

Link to comment
Share on other sites

Link to comment
Share on other sites

Link to comment
Share on other sites

Link to comment
Share on other sites

Tell me, how can i recieve the last message sent to my gmail?

Now i get always X message (history).

I need to create a func that go to my gmaio, get the unread messages, and find a specific message.

Does your script can handle this assignment?

Visit My Website

Link to comment
Share on other sites

Tell me, how can i recieve the last message sent to my gmail?

Now i get always X message (history).

I need to create a func that go to my gmaio, get the unread messages, and find a specific message.

Does your script can handle this assignment?

Gmail only sends the first 301 unread emails so if you have more then that, then I need to figure out how to get the listing of the rest of them. If you have less then 300 new messages, then this script can get your last message.

POP has no search command

http://tools.ietf.org/html/rfc1939#section-9

Thus you would have to download every message and search it locally, if you wanted to find a specific message.

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