Sending Mail

Moderator: Rathinagiri

User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Sending Mail

Post by Rathinagiri »

Wonderful! Thank you Grigory. I will also try!
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Sending Mail

Post 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
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: Sending Mail

Post 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)
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Sending Mail

Post by mol »

I've used ssl without installing openssl (not gmail account)
It works, strange? (or I'm not learned enough :-) most possible :-D )
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: Sending Mail

Post 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.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: Sending Mail

Post 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...
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
Post Reply