Page 2 of 2

Re: Sending Mail

Posted: Tue Sep 01, 2015 3:58 am
by Rathinagiri
Wonderful! Thank you Grigory. I will also try!

Re: Sending Mail

Posted: Tue Sep 01, 2015 6:01 am
by mol
I'm using hb_sendmail() in another solution and it's work OK.
Please point, which dll's we need to copy to app folder to work with SSL.

Regards, Marek

Re: Sending Mail

Posted: Tue Sep 01, 2015 12:20 pm
by Roberto Lopez
mol wrote:I'm using hb_sendmail() in another solution and it's work OK.
Please point, which dll's we need to copy to app folder to work with SSL.
libeay32.dll and ssleay32.dll.

I've downloaded SSL from: http://slproweb.com/products/Win32OpenSSL.html

The test machine is Windows 7 Starter 32 bits.

I'm testing with a console app.

I've built using hbmk2 and plain Harbour.

Code: Select all

@echo off
cls
set path=c:\hmg.3.4.1\harbour\bin;c:\hmg.3.4.1\mingw\bin
hbmk2 test.prg hbssl.hbc hbtip.hbc 
pause
This is the code:

Code: Select all

REQUEST __HBEXTERN__HBSSL__
*----------------------------------------------------------------------*
Function Main
*----------------------------------------------------------------------*

	SETMODE(25,80)

	SETCURSOR(0)

	SETCOLOR('W+/B')

	CLS

	@ 0  , 0 SAY REPLICATE( '-', 80 )
	@ 1  , 1 SAY 'MAIL TEST'
	@ 2  , 0 SAY REPLICATE( '-', 80 )
	@ 22 , 0 SAY REPLICATE( '-', 80 )
	@ 23 , 1 SAY 'STATUS: WAITING'

	@ 24 , 0 SAY REPLICATE( '-', 80 )

	@ 06, 22 SAY 'OPTIONS'

	@ 08, 22 SAY '1. SEND'

	@ 12, 22 SAY 'ESC. EXIT'

	DO WHILE .T.

		K := INKEY(0.9)

		IF	K == 49

			cTO	:= 'mail.box.hmg@gmail.com'
			cBody	:= 'Body!' 
			cSubject:= 'Subject!'

			SEND ( cTO , cSubject , cBody )

		ELSEIF	K == 27

			QUIT

		ENDIF

	ENDDO

RETURN

*----------------------------------------------------------------------*
PROCEDURE SEND ( cTO , cSubject , cBody )
*----------------------------------------------------------------------*

	IF ! tip_SSL()
		ALERT ( "ERROR SSL" )
		RETURN
	ENDIF

	@ 23 , 1 SAY 'STATUS: STARTING ' + DTOC(DATE()) + ' ' + TIME()

	cFrom		:= "your.user.id@gmail.com"            
	cPassword	:= "your.password"        

	R := hb_SendMail(  "smtp.gmail.com",  465,	;
		cFrom,					;
		cTo,					;
		NIL /* CC */,				;
		{} /* BCC */,				;
		cBody,					;
		cSubject,				;
		NIL /* attachment */,			;
		cFrom,					;
		cPassword,				;
		"",					;
		NIL /* nPriority */,			;
		NIL /* lRead */,			;
		.T. /* lTrace */,			;
		.F.,					;
		NIL /* lNoAuth */,			;
		NIL /* nTimeOut */,			;
		NIL /* cReplyTo */,			;
		.T. )

	IF R
		@ 23 , 1 SAY 'STATUS: SEND OK    ' + DTOC(DATE()) + ' ' + TIME() + SPACE(40)
	ELSE
		@ 23 , 1 SAY 'STATUS: SEND ERROR ' + DTOC(DATE()) + ' ' + TIME() + SPACE(40)
	ENDIF

RETURN

I've not tested with HMG yet (I've not investigated about how to include the additional hbc files required in the current version or if it is needed at all)

Re: Sending Mail

Posted: Tue Sep 01, 2015 12:55 pm
by mol
I've used ssl without installing openssl (not gmail account)
It works, strange? (or I'm not learned enough :-) most possible :-D )

Re: Sending Mail

Posted: Tue Sep 01, 2015 1:08 pm
by Roberto Lopez
Roberto Lopez wrote: I've not tested with HMG yet (I've not investigated about how to include the additional hbc files required in the current version or if it is needed at all)
Well... I've tried to build with HMG.3.4.1 (from IDE) but I was unable to do it.

How could this be done?

TIA.

Re: Sending Mail

Posted: Tue Sep 01, 2015 1:13 pm
by Roberto Lopez
mol wrote:I've used ssl without installing openssl (not gmail account)
It works, strange? (or I'm not learned enough :-) most possible :-D )
Maybe the account you used not required SSL auth or SSL dlls are already in your Windows system folder...