Page 1 of 2

hb_sendmail()

Posted: Wed Jun 16, 2010 7:04 pm
by Roberto Lopez
Hi All,

Has anyone a working sample of hb_sendmail()?

TIA.

Re: hb_sendmail()

Posted: Thu Jun 17, 2010 10:34 am
by Alex Gustow
Hi Roberto!

I created "mail robot" :) few months ago (recieving mails with attaches, analyzing mail's content, saving attaches to pre-defined subfolders, send "auto-answers", creating HTML-log).

If needed I can translate this (from Rus to Eng) and "designed" as a sample.
(it's console app compiled with xHarbour - I had some strange troubles with compiling it with "simple" Harbour)

What's the question(s) you have about Hb-SendMail()?

Re: hb_sendmail()

Posted: Thu Jun 17, 2010 11:36 am
by gfilatov
Roberto Lopez wrote:Hi All,

Has anyone a working sample of hb_sendmail()?
Sure.

Please take a look for the following working code using free mail server with authentication:

Code: Select all

   cSMTPServer   := "smtp.freemail.ru"
   cPopServer    := "pop.freemail.ru"
   cFrom         := "gfilatov@freemail.ru"
   cTo           := "recipient@domain.com"
   cSMTPPassWord := "MySmtpPassword"

// hb_SendMail( cServer, nPort, cFrom, xTo, xCC, xBCC, cBody, cSubject, aFiles, cUser, cPass, cPopServer, nPriority, lRead, bTrace, lPopAuth, lNoAuth, nTimeOut, cReplyTo, lTLS, cSMTPPass, cCharset, cEncoding )

   MsgInfo( iif(hb_SendMail( cSMTPServer,;
                  NIL,;
                  cFrom,;
                  cTo,;
                  NIL /* CC */,;
                  NIL /* BCC */,;
                  "test: body",;
                  "test: subject",;
                  {"sendmail.prg"} /* attachment */,;
                  cFrom,;
                  cSMTPPassword,;
                  cPopServer,;
                  NIL /* nPriority */,;
                  NIL /* lRead */,;
                  .F. /* lTrace */,;
                  .T. /* lPopAuth */,;
                  .F. /* lNoAuth */,;
                  NIL /* nTimeOut */,;
                  NIL /* cReplyTo */,;
                  .F. /* lTLS */,;
                  cSMTPPassWord ), "Successfully", "Unsuccessfully"), "Result" )
Hope that helps :idea:

Re: hb_sendmail()

Posted: Thu Jun 17, 2010 12:48 pm
by Roberto Lopez
gfilatov wrote:
Roberto Lopez wrote:Hi All,

Has anyone a working sample of hb_sendmail()?
Sure.

Please take a look for the following working code using free mail server with authentication:

Code: Select all

   cSMTPServer   := "smtp.freemail.ru"
   cPopServer    := "pop.freemail.ru"
   cFrom         := "gfilatov@freemail.ru"
   cTo           := "recipient@domain.com"
   cSMTPPassWord := "MySmtpPassword"

// hb_SendMail( cServer, nPort, cFrom, xTo, xCC, xBCC, cBody, cSubject, aFiles, cUser, cPass, cPopServer, nPriority, lRead, bTrace, lPopAuth, lNoAuth, nTimeOut, cReplyTo, lTLS, cSMTPPass, cCharset, cEncoding )

   MsgInfo( iif(hb_SendMail( cSMTPServer,;
                  NIL,;
                  cFrom,;
                  cTo,;
                  NIL /* CC */,;
                  NIL /* BCC */,;
                  "test: body",;
                  "test: subject",;
                  {"sendmail.prg"} /* attachment */,;
                  cFrom,;
                  cSMTPPassword,;
                  cPopServer,;
                  NIL /* nPriority */,;
                  NIL /* lRead */,;
                  .F. /* lTrace */,;
                  .T. /* lPopAuth */,;
                  .F. /* lNoAuth */,;
                  NIL /* nTimeOut */,;
                  NIL /* cReplyTo */,;
                  .F. /* lTLS */,;
                  cSMTPPassWord ), "Successfully", "Unsuccessfully"), "Result" )
Hope that helps :idea:
Thanks!

Re: hb_sendmail()

Posted: Thu Jun 17, 2010 12:51 pm
by Roberto Lopez
Alex Gustow wrote:Hi Roberto!

I created "mail robot" :) few months ago (recieving mails with attaches, analyzing mail's content, saving attaches to pre-defined subfolders, send "auto-answers", creating HTML-log).

If needed I can translate this (from Rus to Eng) and "designed" as a sample.
(it's console app compiled with xHarbour - I had some strange troubles with compiling it with "simple" Harbour)

What's the question(s) you have about Hb-SendMail()?
Thanks for the offer.

My needs are simpler. I'm only need to send a message to a list of recipients.

I'll try with Grigory sample.

I've posted the question, because I receive astrange error message. I guess that I've missed the parameters.

Thanks Again!

Re: hb_sendmail()

Posted: Thu Jun 17, 2010 1:52 pm
by Roberto Lopez
Roberto Lopez wrote: Thanks!
Ok.

The problem was I've attempted to activate TLS, since that I'm testing with a gmail account.

When you set TLS to .t., you'll get an error 'operation not supported'.

So, there is no errors, but the operation is unsuccessful. I guess the TLS is mandatory for Google.

Anyway, there is a way to know the error code, to find what exactly is happening?

Re: hb_sendmail()

Posted: Thu Jun 17, 2010 2:16 pm
by Roberto Lopez
Roberto Lopez wrote:
Anyway, there is a way to know the error code, to find what exactly is happening?
I've activated trace and I've found the error 512.

If someone can successfully access gmail smtp, please, let me know.

At the moment, I'm using blat. It connects google without problems.

Re: hb_sendmail()

Posted: Thu Jun 17, 2010 2:33 pm
by Alex Gustow
OK, Roberto, I understood your needs.
Sorry, but I hasn't gmail account and can't help in such situation :(

Re: hb_sendmail()

Posted: Thu Jun 17, 2010 2:47 pm
by gfilatov
Roberto Lopez wrote:
Roberto Lopez wrote:
Anyway, there is a way to know the error code, to find what exactly is happening?
I've activated trace and I've found the error 512.

If someone can successfully access gmail smtp, please, let me know.

At the moment, I'm using blat. It connects google without problems.
Roberto,

AFAIR you will need to recompile the Harbour contrib hbtip library with HB_HAS_OPENSSL option for SSL support.
...
2009-08-07 04:11 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbtip/sendmail.prg
! Raised timeout to 1000 from 100.
This was the remaining error, now it should be okay.
; This means Harbour now support SMTP through SSL, which
practically means "gmail support", Google Apps for
Domain mailboxes also work.
Remember to build hbtip with HB_HAS_OPENSSL option and
link with hbssl lib + openssl libs. On *nixes this is
a no-brainer. On Windows, OpenSSL either needs to be
built from source, or pre-built binaries downloaded
(from this file: http://www.slproweb.com/download/Win32O ... 0_9_8k.exe
from this link: http://www.slproweb.com/products/Win32OpenSSL.html)
and linked. Due to usual chaos regarding lib names
on Windows, default names in contrib\hbssl\hbssl.hbc may
need to be adjusted to local environment.
MinGW and MSVC are supported by OpenSSL on Windows for
static linking, the .dll version should work for all
compilers, I've only tested MinGW and MSVC though.

+ contrib/hbtip/tests/gmail.prg
+ Added simple test program to send mails through gmail.
...
Hope that give you an idea :idea:

Re: hb_sendmail()

Posted: Thu Jun 17, 2010 3:09 pm
by Roberto Lopez
gfilatov wrote: Roberto,

AFAIR you will need to recompile the Harbour contrib hbtip library with HB_HAS_OPENSSL option for SSL support.
I don't knew that.

I'll try.

Thanks for the info.