March 28, 2024, 05:22:10 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Email Client

Started by ckoehn, October 09, 2012, 09:14:07 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ckoehn

Can the Client/Server library be use to connect to an email server like pop.gmail.com and download email messages?

Later,
Clint

LarryMc

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

ckoehn

Thanks for answering, LarryMc.  Even if you don't know.

I sure wish sapero was still around.  He had answers to almost any question.  :'(

Later,
Clint

LarryMc

Quote from: ckoehn on October 09, 2012, 11:30:18 AM

I sure wish sapero was still around.  He had answers to almost any question.  :'(

You can't imagine how much I've missed him!
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

ckoehn

Larry,

I imported this library (OpenSSL) and the import info is below.  How can I tell what the function/subs are in the library?  I think this is what I need to open a SSL connection to a server.

QuoteMAKELIB v1.0 (C) Copyright 2005 Ionic Wind Software
All Rights Reserved.

235 exports in C:\openssl-1.0.0j\libssl32.dll
Import Library Created

Later,
Clint

LarryMc

For starters you'll need to go to http://openssl.org/docs/ssl/ssl.html to look through the docs.
Then you'll have to covert the headers from c to IWB.

(I looked through everything I had to see if the headers had been previously converted and couldn't find anything.)

Now you know everything I know about the subject.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

ckoehn

Thanks, LarryMc,

I was afraid there was no easy way to do it.
I searched and tried all kinds of things yesterday and all I ended up with was $10 poorer and a migraine.  :(

Now, back to work.....


Later,
Clint

ckoehn

I don't know if you can help me with this or not LarryMc.

The code below looks like it is a class definition, am I right?  It includes members and methods (mostly methods), right?  I am not real familiar with class programming, but I understand the concept.

/* Used to hold functions for SSLv2 or SSLv3/TLSv1 functions */
typedef struct ssl_method_st
{
int version;
int (*ssl_new)(SSL *s);
void (*ssl_clear)(SSL *s);
void (*ssl_free)(SSL *s);
int (*ssl_accept)(SSL *s);
int (*ssl_connect)(SSL *s);
int (*ssl_read)(SSL *s,void *buf,int len);
int (*ssl_peek)(SSL *s,void *buf,int len);
int (*ssl_write)(SSL *s,const void *buf,int len);
int (*ssl_shutdown)(SSL *s);
int (*ssl_renegotiate)(SSL *s);
int (*ssl_renegotiate_check)(SSL *s);
long (*ssl_get_message)(SSL *s, int st1, int stn, int mt, long
max, int *ok);
int (*ssl_read_bytes)(SSL *s, int type, unsigned char *buf, int len,
int peek);
int (*ssl_write_bytes)(SSL *s, int type, const void *buf_, int len);
int (*ssl_dispatch_alert)(SSL *s);
long (*ssl_ctrl)(SSL *s,int cmd,long larg,void *parg);
long (*ssl_ctx_ctrl)(SSL_CTX *ctx,int cmd,long larg,void *parg);
const SSL_CIPHER *(*get_cipher_by_char)(const unsigned char *ptr);
int (*put_cipher_by_char)(const SSL_CIPHER *cipher,unsigned char *ptr);
int (*ssl_pending)(const SSL *s);
int (*num_ciphers)(void);
const SSL_CIPHER *(*get_cipher)(unsigned ncipher);
const struct ssl_method_st *(*get_ssl_method)(int version);
long (*get_timeout)(void);
struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */
int (*ssl_version)(void);
long (*ssl_callback_ctrl)(SSL *s, int cb_id, void (*fp)(void));
long (*ssl_ctx_callback_ctrl)(SSL_CTX *s, int cb_id, void (*fp)(void));
} SSL_METHOD;


Later,
Clint

Copex

Quote from: ckoehn on October 09, 2012, 09:14:07 AM
Can the Client/Server library be use to connect to an email server like pop.gmail.com and download email messages?

Later,
Clint

yes.... there are a few things you need to know, (passwords are sent using base64 it maybe helpful to know this.)

read this

http://kb.mediatemple.net/questions/889/Sending+or+viewing+emails+using+telnet
http://wiki.mediatemple.net/w/Email_via_IMAP_using_Telnet
http://smanage.tripod.com/tel.html

then

http://en.wikipedia.org/wiki/Post_Office_Protocol
-
I really should learn how to use a spell checker! though im not sure how it will help someone who can not spell?
-
Except where otherwise noted, content Posted By Copex is
licensed under a Creative Commons Attribution 3.0 License

http://creativecommons.org/licenses/by/3.0/

ckoehn

Thanks Copex,

I will accept whatever help I can get!!

Later,
Clint

LarryMc

Clint
That typedef struct doesn't look like anything I've seen before.

But I'm with you it does look like a class definition.
But I know almost zero about c
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

ckoehn

October 11, 2012, 09:39:10 AM #11 Last Edit: October 11, 2012, 10:25:58 AM by ckoehn
Copex,

Could you give me a bit more of a hint on how the Client/Server library would work.  I've been studying the base64 encoding not sure exactly how that works (am still reading).  I feel brain dead other wise.  Doesn't connecting to a server like that require SSL?  Does winsock2 support that?

The socket that is returned by the library is a virtual socket, not the actual socket number, right?

Later,
Clint

Found a post on BASE64 here http://www.ionicwind.com/forums/index.php?topic=2714.msg22878#msg22878

ckoehn

October 11, 2012, 03:24:08 PM #12 Last Edit: October 11, 2012, 03:26:44 PM by ckoehn
This requires the Client/Server Library.  It connects to one of my accounts.  I do not think that server uses SSL.
It will NOT connect to pop.gmail.com or any other account that I have.  Again, I think that I need to use SSL to do that.  I have yet to figure out how to do that with this library.

The password is NOT BASE64 encoded.

$INCLUDE "windowssdk.inc"
'$INCLUDE "BASE64.inc" 'not currently used,  see link in previous post

CONST eBox=1

window w1
uint iwncsStatus=0,datasocket=-1

int numMsg=0,MsgCnt=0

string buffer,decode
string ToSend

'======== Email Settings ======================
string sServer="pop.att.yahoo.com" 'I've only got it to work on this server, I don't think this server uses SSL
int sPort=110 'only on this port
string sEmail="youremailaccount@sbcglobal.net" 'I haven't tried @yahoo.com
string sPassword="yourpassword"
'==============================================


OPENWINDOW w1,0,0,500,400,@TOOLWINDOW|@TOPMOST,0,"Retrieve Email Test",&main
CONTROL w1,@EDIT,"",20,20,460,340,@CTEDITMULTI|@VSCROLL|@HSCROLL,eBox


'======== do this one time ==================================
iwncsStatus = IWNCSInit(1,0)
IF iwncsStatus<0
  addtext(w1,ebox,"Client Error: "+IWNCSGetErrorText(),1)
ENDIF
'============================================================


eConnect(sServer,sPort) 'start the ball rolling :)



WAITUNTIL w1=0

IF datasocket>-1
IWNCSCloseSocket(datasocket)
ENDIF

END



SUB main
SELECT @MESSAGE
CASE @IDCREATE
CENTERWINDOW w1

CASE @IDCLOSEWINDOW
CLOSEWINDOW w1

CASE WM_USER 'callback from Client/Server
iwncsStatus = IWNCSReadDataString(datasocket,buffer,254,500)

WHILE iwncsStatus > 0

buffer[iwncsStatus]=chr$(0)

addtext(w1,ebox,buffer,1)

iwncsStatus = IWNCSReadDataString(datasocket,buffer,254,500)

ENDWHILE

IF iwncsStatus < 0
addtext(w1,ebox,"ERROR :" + STR$(iwncsStatus),1)
ENDIF

'Arm the data message for further data.
iwncsStatus=IWNCSOnDataMessage(w1.Hwnd, datasocket, WM_USER)

IF LEFT$(Buffer,9)="+OK hello" 'send USER
MsgCnt=0
toSend = "USER "+sEmail+"\n"
IWNCSSendDataString(datasocket,toSend,len(toSend)+1)

ELSEIF INSTR(Buffer,"+OK password")>0
toSend = "PASS "+sPassword+"\n"
IWNCSSendDataString(datasocket,toSend,len(toSend)+1)

ELSEIF INSTR(Buffer,"+OK maildrop ready")>0
numMsg=INT(VAL(MID$(Buffer,21)))
addtext(w1,ebox,STR$(numMsg)+" Messages",1)
toSend = "QUIT\n"
IWNCSSendDataString(datasocket,toSend,len(toSend)+1)

ENDIF

ENDSELECT
RETURN 0
ENDSUB

SUB eConnect(string server, int port)
iwncsStatus = IWNCSConnectToServer(server,port)
IF iwncsStatus < 0
addtext(w1,ebox, "Error connecting to server",1)
addtext(w1,ebox,IWNCSGetErrorText()+"\n",1)
ELSE
datasocket = iwncsStatus
addtext(w1,ebox,"Connected to server "+STR$(datasocket)+"\n",1)
iwncsStatus=IWNCSOnDataMessage(w1.hwnd, datasocket, WM_USER)
IF iwncsStatus < 0
addtext(w1,ebox,"IWNCSOnDataMessage error",1)
addtext(w1,ebox,IWNCSGetErrorText()+"\n",1)
ENDIF
ENDIF

RETURN 0
ENDSUB

SUB AddText(window win,int id,string text,int addNL)
int _textlen:_textlen =SendMessage(win, WM_GETTEXTLENGTH,0,0,id)
CONTROLCMD win, id, @EDSETSELECTION, _textlen, _textlen
IF(addNL)
CONTROLCMD win, id, @EDREPLACESEL, text + "\n"
ELSE
CONTROLCMD win, id, @EDREPLACESEL, text
ENDIF
ENDSUB


Later,
Clint

Copex

Quote from: ckoehn on October 11, 2012, 03:24:08 PM
This requires the Client/Server Library.  It connects to one of my accounts.  I do not think that server uses SSL.
It will NOT connect to pop.gmail.com or any other account that I have.  Again, I think that I need to use SSL to do that.  I have yet to figure out how to do that with this library.

The password is NOT BASE64 encoded.

Later,
Clint

have a read of this http://technet.microsoft.com/en-us/library/aa995718%28v=exchg.65%29.aspx when sending an email using SMTP with authentication the user name and password is encode using bace64 sorry i didt make this clear.

gmail require ssl most pop3 accounts will work with out SSL/TLS

my post was just to point you in the right direction! Telnet will help you understand the messaging process.   
-
I really should learn how to use a spell checker! though im not sure how it will help someone who can not spell?
-
Except where otherwise noted, content Posted By Copex is
licensed under a Creative Commons Attribution 3.0 License

http://creativecommons.org/licenses/by/3.0/

Copex

http://www.cs.auckland.ac.nz/~pgut001/cryptlib/

maybe easier to use than openssl - you will have to code your own headers.
-
I really should learn how to use a spell checker! though im not sure how it will help someone who can not spell?
-
Except where otherwise noted, content Posted By Copex is
licensed under a Creative Commons Attribution 3.0 License

http://creativecommons.org/licenses/by/3.0/

ckoehn

Thanks again Copex.

Like I said, I'll take any help I can get.  Looks like I have some more reading to do.

Later,
Clint